How would one write a Case Statement with a count greater than one? The below is what I have so far: I'm receiving an invalid identifier.
Select *, CASE WHEN COUNT(X.id ) >1 THEN X
ELSE isnull END AS testing
from TestTable
Thanks for the comments. I was able to work through my problem as I'm new to Oracle.
The correct statement would be:
Select *, CASE WHEN COUNT(X.id ) >1 THEN 'X'
ELSE '' END AS testing
from TestTable
Group by *
COUNT itself is an aggregate function that you have to use with GROUP BY. But you can also use it as an analytic function:
SELECT t.*, CASE WHEN COUNT(t.id) OVER(PARTITION BY ...) > 1 THEN 'X'
ELSE '' END AS testing
FROM TEST_TABLE
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.