PDA

View Full Version : Count unique instances of a column in relation to another column?



JGalper
08-17-2012, 09:57 AM
Using SSMS 2008 to query SQL Server 2005 -
I have a table with data that is similar to below:

A B C
1 11 111
2 11 111
3 11 112
4 11 112
5 12 113
6 12 113
7 12 113
8 12 113
9 13 114
10 13 114

As you can see, the first column is unique, the second column refers to the created instance, and the third column refers to the order that falls against the number in column B.

I would like to create a SQL query that would allow me to pull all numbers from column B that have more than one number in C assigned to it. In the above example it would be number '11' in row B because it has numbers '111' and '112' from column C in it.



Edit: Added some info