Error when using SUM on a text value
When I run
SELECT SUM(CASE column1 WHEN 'sometext' THEN 1 ELSE 0 END)
FROM table1
I get the following error: "The data types text and varchar are
incompatible in the equal to operator." The column is datatype text so i
tried the following but got the same error. Any ideas?
SELECT SUM(CASE column1 WHEN CAST('sometext' AS VARCHAR (40)) THEN 1 ELSE
0 END)
FROM table1
No comments:
Post a Comment