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 |
|
Grinja
Starting Member
5 Posts |
Posted - 2008-01-18 : 06:25:49
|
| Hi,I need to identify where a combination of 3 Columns occurs more than once.What I have so far (simplified for the post)SELECT A, B,CFROM tblXGROUP BY A,B,CHAVING COUNT A > 1AND COUNT B > 1AND COUNT C > 1Any help would be appreciated. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-01-18 : 07:04:23
|
SELECT A,B,CFROM tblXGROUP BY A,B,CHAVING COUNT(*) > 1 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Grinja
Starting Member
5 Posts |
Posted - 2008-01-18 : 07:22:29
|
| Thanks for input... I have tried this but get the same result as my previous code.Lets say values are as follows:ColA = Peter ColB = SmithColC = XI want to identify the records where the combinationPeter Smith X appears more than once.When I tried HAVING (Count *) I got combination as follows:Row1 - Peter Smith XRow2 - Peter Smith YThanks for the help so far. |
 |
|
|
Grinja
Starting Member
5 Posts |
Posted - 2008-01-18 : 07:33:20
|
I tried this HAVING COUNT(A + B + C) > 1I got the same result as HAVING COUNT (*)If I take the result from the above and use a SELECT as follows:SELECT A,B,CWHERE A=Peter AND B=SmithAND C=XI get one row returned ... shouldn't it get more than 1?I think I'm missing somthing.. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-18 : 07:49:15
|
quote: Originally posted by Grinja I tried this HAVING COUNT(A + B + C) > 1I got the same result as HAVING COUNT (*)If I take the result from the above and use a SELECT as follows:SELECT A,B,CWHERE A=Peter AND B=SmithAND C=XI get one row returned ... shouldn't it get more than 1?I think I'm missing somthing..
Did you try Peso's query?MadhivananFailing to plan is Planning to fail |
 |
|
|
Grinja
Starting Member
5 Posts |
Posted - 2008-01-18 : 08:25:36
|
Sorry had a real blonde moment All the above worked fine . In my original query there are numerous sub queries ... I left a SELECT DISTINCT in one of them.Thanks for the help. |
 |
|
|
|
|
|
|
|