Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capitalize the first letter of words in Snowflake?

I need to capitalize the first letter of certain words in my SQL qwery in Snowflake.

I am currently using this function:

SELECT ...
    case when FLAG1 is null then upper(FLAG2) else FLAG1 END as STATUS,
...;

The UPPER() function however renders all my FLAG2 words to be fully capitalized. Anyone know how to capitalize the first letter of words in Snowflake?

like image 973
Justine Mit Avatar asked Oct 16 '25 17:10

Justine Mit


1 Answers

Use initcap() function, it returns the input string (expr) with the first letter of each word in uppercase and the subsequent letters in lowercase.

If you want only first letter in a string to be capitalized, ignoring word delimiters (i.e. the input expression is treated as a single, continuous word), specify empty string as delimiters parameter

INITCAP( str, '')
like image 72
leftjoin Avatar answered Oct 18 '25 07:10

leftjoin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!