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.
| Author |
Topic |
|
lord_remorin
Starting Member
2 Posts |
Posted - 2009-05-29 : 08:18:46
|
| hi,please help me, im new in using sqli have this tablename tags-----------john 1stjohn 1stjohn 2ndjohn 3rdmark 1stmark 2ndmark 2ndmark 3rdmark 3rdrob 1strob 1strob 3rdand i want the result to be displayed like thisname tags count-----------------john 1st 2john 2nd 1john 3rd 1mark 1st 1mark 2nd 2mark 2nd 2rob 1st 2rob 3rd 1please help me build my querythanks in advance!LoRd |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-29 : 08:29:34
|
[code]select name, tags, count = count(*)from tablegroup by name, tags[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-29 : 08:32:49
|
SELECT Name, Tags, COUNT(*) AS CountFROM Table1GROUP BY Name, TagsORDER BY Name, Tags E 12°55'05.63"N 56°04'39.26" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-29 : 08:33:53
|
I was confues by the erraneous expected output...Where is "mark 2rd" and why is "mark 2nd" twice? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
lord_remorin
Starting Member
2 Posts |
Posted - 2009-05-29 : 08:34:06
|
| hi,thanks a lot!i didn't know that i could group multiple fields..thanks again.LoRd |
 |
|
|
|
|
|