Simple SQL [PostgreSQL]
Code\npostgresql []\n-- addejans\n\nWITH formatted_content AS (\n    SELECT \n        content_id,\n        content_text AS original_text,\n        STRING_AGG(\n
# Code\n```postgresql []\n-- addejans\n\nWITH formatted_content AS (\n    SELECT \n        content_id,\n        content_text AS original_text,\n        STRING_AGG(\n            CASE \n                WHEN word LIKE \'%-%\' THEN\n                    -- Split hyphenated words, capitalize each part, and rejoin\n                    ARRAY_TO_STRING(ARRAY(\n                        SELECT INITCAP(part) \n                        FROM UNNEST(string_to_array(word, \'-\')) AS part\n                    ), \'-\')\n                ELSE\n                    -- Capitalize non-hyphenated words\n                    INITCAP(word)\n            END, \' \') AS converted_text\n    FROM (\n        SELECT \n            content_id,\n            content_text,\n            UNNEST(string_to_array(content_text, \' \')) AS word\n        FROM user_content\n    ) AS words\n    GROUP BY content_id, content_text\n)\nSELECT content_id, original_text, converted_text\nFROM formatted_content\nORDER BY content_id;\n\n```
['PostgreSQL']