How we can get the salary whose is earning more than one person and also i want his name also to display...Ex:-If there is 5 members are there who is earning more than the JonesOutput I want is:Jones 2500 hari 2600Jones 2500 king 5000Jones 2500 rakesh 6000Jones 2500 rajesh 6500Jones 2500 ramesh 7000

Showing Answers 1 - 6 of 6 Answers

tarun1282

  • Apr 12th, 2006
 

hiselect b.first_name,b.salary,e.first_name,e.salaryfrom employees,(select first_name,salary from employees where first_name='Jones') bwhere e.salary>b.salary;

  Was this answer useful?  Yes

raj

  • Apr 14th, 2006
 

select * from where more salary emp code=b

  Was this answer useful?  Yes

mannam07

  • Jul 19th, 2007
 


 select a.ename,a.sal,b.ename,b.sal from emp a,emp  b where a.ename='CLARK' and
a.ename<>b.ename and a.sal<b.sal;

  Was this answer useful?  Yes

Vijay Krishnan

  • Jul 20th, 2007
 

Try this
select b.sname,b.salary,a.sname,a.salary from sales b inner join sales a on a.sname = 'vijay' and b.salary > a.salary

  Was this answer useful?  Yes

venkat2182

  • Aug 9th, 2007
 

Hi....

I hope u know about "self-join". The following query will give the above result.


SELECT e1.name,e1.salary,e2.name,e2.salary FROM emp_test e1,emp_test e2
WHERE e1.name='Jones' FROM emp_test
AND e2.salary>e1.salary


Suppose u dont know who get min salary, u can use the following query,

SELECT e1.name,e1.salary,e2.name,e2.salary FROM emp_test e1,emp_test e2
WHERE e1.name=(SELECT name FROM emp_test WHERE salary=(SELECT Min(salary) FROM emp_test))
AND e2.salary>e1.salary

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions