Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return records where column2 contains different values with column1 having the same value 1

Status
Not open for further replies.

jasonhuibers

Programmer
Sep 12, 2005
290
0
0
CA
Name column:
Height column

Name column contains the same value but the Hight column is different.

IE:
NAME HEIGHT
John 6FT2
John 6FT2
Shawn 3FT1
Shawn 5FT2

Return SHAWN as Shawn contains multiple records with a different Height value
 
You might try a nested query:

The inner query will find all of the distinct combinations:

SELECT DISTINCT name, height FROM myTable;
This will give you
John 6FT2
Shawn 3FT1
Shawn 5FT2

The outer query will find the names with multiple heights:

SELECT name
FROM (inner query)
GROUP BY name
HAVING count(*) > 1;

This will give you Shawn.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top