By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,410 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,410 IT Pros & Developers. It's quick & easy.

Count group by query

P: 109
I need to write a query which would give me result like this:

name Code1 code2 code3 ect

J Doe 10 2 3

J Smith 8 5 4

and so on...

I have a table which holds a name and this code.

there is muptiple entry of each code with each person i need to find out how many times a perticuler person has recorded a perticular code.

so my table looks like this,

ID name code date
1 j doe code1 1/1/2000
2 j Smith code3 1/1/2000
3 j doe code2 1/1/1900
4 j lulla code10 1/1/2005
5 J doe code1 1/1/2006

so on,

can someone help me with this?

I can do a count individually but that it too time consuming as I have 1000+ names and 100+ codes.

so, is there a way to do all in once?

Thank you in advaned for your help and suggestions.

Aug 19 '09 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 2,878
Looks like a PIVOT/UNPIVOT would help you.

Happy Coding!

--- CK
Aug 20 '09 #2

P: 135
What did you try so far? Post your SQL's.
Aug 20 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.