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

Duplicate area problem

Status
Not open for further replies.

lfcmd

Programmer
May 3, 2006
14
IE
Hi All

Quick Query, i have table that basically looks like

CName Id Area
Dunnes 10 11
Dunnes 10 12
Quinn 11 13
Quinn 11 14
Quinn 11 11
Tesco 12 12
Tesco 12 13

From the example above i want to find all CName whos name is 'dunnes' or 'quinn' and also have the same Area.

So result i would need from example above would be

Dunnes 11
Quinn 11
 

Something like
[tt]
select cname,area
from thetable
where cname in ('dunnes','quinn')
group by cname,area
having count(*)>1
[/tt]
 
ye had tried somethin along those lines and just tried your example there now but getting no records returned when i run the query
 

Is your installation configured for case-sensitive compares?

Is the "area" column text or integer?

Do any of the names have trailing spaces?

 
no not case - sesitive
"area" column is integer
no trailing spaces after the names
 

Sorry, I misread the actual requirement. Try this:
[tt]
select cname,area
from thetable
where area in
(select area
from thetable
where cname in ('dunnes','quinn')
group by area
having count(*)>1)
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top