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 |
|
jpazcosta
Starting Member
5 Posts |
Posted - 2008-05-29 : 18:58:00
|
| hi everyone, I have a table: HelpA B C05/01/2008 100 1 05/01/2008 100 205/01/2008 100 205/02/2008 200 1 05/02/2008 200 2SELECT a, COUNT(c) FROM Help GROUP BY aResult: 1> 05/01/2008 32> 05/02/2008 2 But I need grouping columns B and C so that the result was 1> 05/01/2008 22> 05/02/2008 2Is it possible? How can I do?Thanks. |
|
|
dshelton
Yak Posting Veteran
73 Posts |
Posted - 2008-05-29 : 20:02:22
|
| SELECT A, COUNT(DISTINCT C) FROM helpGROUP BY A |
 |
|
|
jpazcosta
Starting Member
5 Posts |
Posted - 2008-05-29 : 20:22:15
|
It works well with the example posted, thank you. But if the table would be:A B C05/01/2008 100 1 05/01/2008 100 205/01/2008 100 205/01/2008 200 1 05/01/2008 200 2Result:1> 05/01/2008 2I need:1> 05/01/2008 4Thanks !!!quote: Originally posted by dshelton SELECT A, COUNT(DISTINCT C) FROM helpGROUP BY A
|
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-29 : 20:24:47
|
| SELECT A, COUNT(*)FROM YourTableGROUP BY A, B, CTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
jpazcosta
Starting Member
5 Posts |
|
|
jpazcosta
Starting Member
5 Posts |
Posted - 2008-05-30 : 19:46:44
|
| SELECT A, COUNT(DISTINCT B + C)FROM helpGROUP BY AThanks for the help !!!!!!!! |
 |
|
|
|
|
|
|
|