Reputation: 546
I need to count rows where the value of Master.[Date BP] is not Null - any ideas how I would do this?
I tried this but it doesn't seem to work.
SELECT Master.[Date BP], Count(Master.[Date BP]) AS CountOfField,
FROM Master
GROUP BY Master.[Date BP];
Upvotes: 2
Views: 869
Reputation: 1
The above answers are correct. Just in case you may face other problems with other aggregate functions, aggregate functions in SQL will ignore the null value.
Reference: https://msdn.microsoft.com/en-us/library/ms173454.aspx
Upvotes: 0
Reputation: 311338
Using count
is the right idea. You just need to remove the group by
clause, as you want a single answer. Additionally, you have a redundant comma at the end of the select list:
SELECT Count(Master.[Date BP]) AS CountOfField
FROM Master
Upvotes: 2