Returning Null values with COUNT
Posted
by
Randy B.
on Stack Overflow
See other posts from Stack Overflow
or by Randy B.
Published on 2012-11-26T22:53:32Z
Indexed on
2012/11/26
23:03 UTC
Read the original article
Hit count: 157
sql
|sql-server-2008
With this query, I get a result that is two short of the table because they are not included in count, and I would like get the NULL values in the result. To do this, I am pretty sure I need to use a subquery of some kind, but I am not sure how, since the attribute in question is an aggregate.
SELECT Equipment.SerialNo , Name, COUNT(Assignment.SerialNo)
FROM Equipment
INNER JOIN Assignment
ON Assignment.SerialNo = Equipment.SerialNo
GROUP BY Equipment.SerialNo, Name
© Stack Overflow or respective owner