[thelist] SQL query to create aging buckets
Joshua Olson
joshua at waetech.com
Wed Dec 17 16:23:13 CST 2003
From: "Joel D Canfield" <joel at spinhead.com>
Sent: Wednesday, December 17, 2003 5:11 PM
> > SELECT datediff(d,duedate,getdate()), Count(*) AS TheCount
>
> How does 'Count(*)' know what it's counting? What is the wildcard
> matching? BOL isn't offering an answer
>
> It works; I just wanna know why
Joel,
No problem.
<tip type="SQL" author="Joshua Olson">
When you add Count(*) to the select list of a grouped query you are asking
the database to return the number of items in each group.
When you add Count(columnname) to the select list of a grouped query you are
asking the database to return the number of non-NULL values for that column
within each group.
The * in this context has slightly different meaning than when it is in the
SELECT list by itself (which means return all columns).
</tip>
<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com/service_areas/GA/
706.210.0168
More information about the thelist
mailing list