Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Doubt

Author  Topic 

vmurali
Yak Posting Veteran

88 Posts

Posted - 2007-12-10 : 02:07:43
Find employee who is living in more than one city.
Two Tables:
Emp City
Empid Empid
empName City
Salary

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-10 : 02:21:41
Have you tried anything so far?
It seems that after posting a question you dont follow up

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

vmurali
Yak Posting Veteran

88 Posts

Posted - 2007-12-10 : 02:35:33
I have tried
select b.Emp_Id,b.City from emp_City b join Employee a
on a.Emp_id = b.Emp_id group by b.emp_id,b.city having count(b.emp_id) > 1
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2007-12-10 : 02:53:05
Change the query like this (exclude parts in red)

select b.Emp_Id,b.City from emp_City b join Employee a
on a.Emp_id = b.Emp_id group by b.emp_id,b.city having count(b.City) > 1
Go to Top of Page
   

- Advertisement -