Okay, this problem is driving me crazy! There's probably a really simple solution, but whatever it is, I can't see it! 🙂
Basically, I have a date field called "deletedate" in my table. Based on certain criteria (which is irrelevant here), I want to return a count of how many rows have a null value for deletedate, and how many rows have a non-null value. The non-null part is easy - just count(deletedate). But how do I count how many rows have null values?
I think I've achieved this in MySQL:
SELECT count(IF(isnull(p.deletedate),1,null)) as deletedatenull,
count(p.deletedate) as deletedatenotnull
FROM member
WHERE ... etc.
A little messy, but it switches the null and non-null values around, and then does the count. The problem is that I now need to achieve the same in PostgreSQL (ie. it needs to be rewritten without the IF and ISNULL). Does anyone have any ideas on how I can achieve this? Any help would be very much appreciated 🙂
Emily