Regexp_count with datatype of character varying text

Viewed 13

I'm working with a SQL script run on an AWS RedShift cluster and see that a previous developer used the following syntax with regexp_count expression:

SELECT REGEXP_COUNT(SOME_COLUMN::TEXT, 
                    ','::CHARACTER VARYING::TEXT) AS TOTAL
FROM SOME_TABLE

Can anyone tell me what the cast statement on the comma does? Why is is not possible to cast the comma directly to text, i.e.,

','::TEXT

And if that is not possible, what does the CHARACTER VARYING operator do that makes it convertible to text

0 Answers
Related