How do I implement the 'meaning' of the following psuedo-SQL statement:
COUNT(distinct id where attribute1 > 0)
In other words, how do I make conditional, distinct counting statements?
Thanks!
How do I implement the 'meaning' of the following psuedo-SQL statement:
COUNT(distinct id where attribute1 > 0)
In other words, how do I make conditional, distinct counting statements?
Thanks!
好吧,如果您可以过滤整个查询,那么 LittleBobbyTables 已经为您提供了答案。如果没有,您可以像这样获得该列:
count(distinct case when attribute1 > 0 then id end) -- implicit null-else, iirc
你几乎拥有它:
SELECT COUNT(DISTINCT [ID]) AS DistinctID
FROM YourTable
WHERE attribute1 > 0