Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 Group by and count

Author  Topic 

graabein
Starting Member

16 Posts

Posted - 2006-11-07 : 09:39:03
This should be easy but I can't figure it out. I have a DataSet that contains among other fields OpCode and OpText. Something like this:

KCD02 | Hello | Jimmy
MCA10 | Howdy | Harold
MCA10 | Howdy | Gary
TA761 | Hola | Lola

I want to make a table where I group OpCode together with the belonging OpText and count of each like this:

1 KCD02 Hello
2 MCA10 Howdy
1 TA761 Hola

What cells do I need and what expression do they have?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-07 : 10:29:45
select count(*), opcode, optext from mytable
group by opcode, optext


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -