Home All Groups Group Topic Archive Search About

Newbie question - Need count to return multiple values

Author
19 May 2006 3:02 PM
Nancy R
Hi all,

This is probably a simple question but I still new enough that I can't
figure it out (this is only my second real query i'm so REALLY new).

I have a table that looks like this:

CustKey       InvoiceDate
01               2006-05-19
02               2006-05-19
03               2006-05-19
04               2006-04-28
02               2006-05-19
03               2006-05-19
04               2006-05-19
04               2006-05-19
03               2006-05-19

I want my output to look like this:

CustKey          Total for 2006-05-19
01                   1
02                   2
03                   3
04                   2

Basically I need a list that will tell me, by CustKey, how many Invoices
were done on a given day.

Now I can do a quick count that will tell me for a given customer and date
but I don't know how to have it check and return values for all 4 customers
based on date.

So far I have:

SELECT COUNT * FROM "Table1"
WHERE CustKey = '01'
AND "InvoiceDate" = ('2006-05-19')

Any help would be appreciated.  I'm trying to save myself from having to do
a manual count of invoices on a weekly basis.

Thanks in advance,
Nancy

Author
19 May 2006 3:08 PM
SQL
SELECT CustKey,COUNT( *) FROM Table1
WHERE InvoiceDate = ('2006-05-19')
GROUP BY CustKey

Denis the SQL Menace
http://sqlservercode.blogspot.com/
Author
19 May 2006 3:20 PM
Nancy R
Thanks Denis, I figured it would be something simple.

This works perfectly!

Show quote
"SQL" wrote:

> SELECT CustKey,COUNT( *) FROM Table1
> WHERE InvoiceDate = ('2006-05-19')
> GROUP BY CustKey
>
> Denis the SQL Menace
> http://sqlservercode.blogspot.com/
>
>

AddThis Social Bookmark Button