I’m racking my brain trying to work out what group by and/or distinct and count() formation help with this but have currently drawn a blank.
Consider the table:
PersonId | PlaceName
---------+----------
1 | NULL
1 | NULL
2 | NULL
2 | Las Vegas
3 | London
4 | NULL
4 | NULL
4 | NULL
I’m looking for people who haven’t bothered to fill in “place names”, so I want my output to look like this:
PersonId
--------
1
4
I’ll actually be joining some other tables in to pull out the info on each “miscreant” person, but the crux of my problem is the one above.
Use the following query:
The
COUNT()aggregate function ignoresNULLs, so the right result should be returned.