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 |
|
spoutnick
Starting Member
6 Posts |
Posted - 2011-08-16 : 06:38:09
|
| HELLO ALL,i have a table like this COL1 COL2 AAA MARAAA MARAAA OUJ BBB OUJBBB MARBBB BNIi would like to use sql query to get AAA 2 BBB 3THANKS IN ADVANCE |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-08-16 : 07:10:18
|
Here is a way to do this:select col1,count(*)from ( select distinct col1,col2 from YourTable) sgroup by col1; |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-08-16 : 07:13:07
|
[code]select COL1, count(distinct COL2)from YourTablegroup by COL1[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-08-16 : 07:18:20
|
| Hah! That is what I missed!! I knew there was a better way to do it!! thanks KH. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-08-16 : 07:19:15
|
quote: Originally posted by sunitabeck Hah! That is what I missed!!
Coffee ?  KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
spoutnick
Starting Member
6 Posts |
Posted - 2011-08-16 : 07:22:33
|
| THANKS IT WORKS |
 |
|
|
|
|
|