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 |
hai
Yak Posting Veteran
84 Posts |
Posted - 2007-06-06 : 09:28:51
|
hi all,I have the following table,c1,c21, 31, 41, 52, 22, 32, 03, 23, 23, 5I want to select if the column c1 is the same, group c1 but count c2eg 1, 32, 33, 2thanks |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-06 : 09:30:48
|
[code]select c1, count(distinct c2)from tblgroup by c1[/code] KH |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-06-06 : 09:31:26
|
Your expected output is wrong.it should be1,32,33,3EDIT: Okay, DISTINCT, that makes sense.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-06-06 : 15:00:20
|
Madhi, are you talking to harsh or hai? [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-07 : 07:10:11
|
quote: Originally posted by DonAtWork Madhi, are you talking to harsh or hai? [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp
Guess MadhivananFailing to plan is Planning to fail |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-07 : 07:16:52
|
me ?  KH |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-07 : 09:53:10
|
quote: Originally posted by khtan me ?  KH
Guess again MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|