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
 General SQL Server Forums
 New to SQL Server Programming
 Query

Author  Topic 

vmurali
Yak Posting Veteran

88 Posts

Posted - 2007-03-05 : 01:31:34

Hi,

I need one query which fetches the list of all the employess having same salary.
Table structure:
Employee (emp_name, emp_id, dept, sal)

Now, I want the list of all the employess who have same salary.


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-05 : 01:33:45
select e.* from employee as e
inner join (SELECT sal from employee group by sal having count(*) > 1) as x on x.sal = e.sal
order by e.sal desc, e.emp_id


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-05 : 01:35:49
Or the basic

select * from employee where sal = @WantedSalary


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -