469,923 Members | 1,333 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

using count somehow

Suppose this is the table data:
col1 col2 col3
item1 3 aa
item1 2 bb
item1 5 aa

Would it be possible to get something like this output:

item1 10 2

where col2 was summed and col3 had the numbers of aa's counted?

that is, select col1, sum(col2), count(number of aa's in col3).

regards,
-David

Jul 23 '05 #1
2 1013
SELECT col1, SUM(col2),
COUNT(CASE WHEN col3 = 'aa' THEN 1 END)
FROM YourTable
GROUP BY col1

--
David Portas
SQL Server MVP
--
Jul 23 '05 #2
Thanks much.

-Dave

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Abhi | last post: by
26 posts views Thread by G Patel | last post: by
68 posts views Thread by Martin Joergensen | last post: by
26 posts views Thread by Ping | last post: by
16 posts views Thread by Joe Strout | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.