I’ve got a table on a MSSQL-Server with a couple of fields:
fieldA,fieldB,fieldC,DateTimeField
now I’m doing a select like this:
SELECT fieldA,fieldB,fieldC, max(DateTimeField),min(DateTimeField),
(count(*) - count(DateTimeField)) as DateTimeFieldIsNull
FROM table
GROUP BY fieldA, fieldB, fieldC
which is working quite well.
Now I want to count all DateTimeFields that are in the past, or in another column, that are in the future.
Is there a perfomant way? (maybe even without JOINING) ?
Thnx, Harry
Just add a COUNT/CASE construct.
You get NULL from the implied
ELSEwhich COUNT ignores