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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

single command

Status
Not open for further replies.

timmyni

Programmer
Nov 16, 2004
3
GB
I have a table users( ...... age int .........)

I want to pick out the users have same age as anyother users. with one SQL statement. How can I do it?
 
Code:
select foo, bar, age
  from users
 where age in
   ( select age
       from users
     group by age
     having count(*) > 1 )

rudy
SQL Consulting
 
how about this one

select id, age
from users
where age in
( select age
from users
group by age
having count(*) > 1 )

 
sorry, pasted the wrong one,


SELECT DISTINCT t1.*
FROM try1 AS t1
INNER JOIN try1 AS t2
ON t1.age = t2.age
AND t1.id <> t2.id
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top