SQL Query

leonstryker
leonstryker used Ask the Experts™
on
I have a two column table.

Col1   Col2
1        A
1        A
1        B
2        C
2        C
3        A
3        B
4        D

I need a list of all records which have same values in column 1, but different values in column 2. From the sample above, it should return:

Col1   Col2
1        A
1        A
1        B
3        A
3        B

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Consultant
Top Expert 2009
Commented:
Hello leonstryker,

SELECT * FROM urTable WHERE Col1 in (

SELECT Col1
FROM ( SELECT DISTINCT Col1, Col2 FROM urTable  ) a
GROUP BY Col1
Having CoUNT(Col1) > 1 )



Regards,

Aneesh

Author

Commented:
Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial