Hi,
Yesterday my friend attended inteview in I B M for database devloper
They asked him simple question .Check it out.
Tell me three ways I can get above result .....
Table -create table Employee (id int,salary money)
1.
SELECT max(salary) FROM Employee WHERE salary NOT IN (SELECT max(salary) FROM Employee);
2.
SELECT max(salary) FROM Employee WHERE salary < (SELECT max(salary) FROM Employee)
3.In sql server - using top keyword
SELECT TOP 1 salary FROM ( SELECT TOP 2 salary FROM employees ORDER BY salary DESC) AS emp
ORDER BY salary ASC
Yesterday my friend attended inteview in I B M for database devloper
They asked him simple question .Check it out.
Tell me three ways I can get above result .....
Table -create table Employee (id int,salary money)
1.
SELECT max(salary) FROM Employee WHERE salary NOT IN (SELECT max(salary) FROM Employee);
2.
SELECT max(salary) FROM Employee WHERE salary < (SELECT max(salary) FROM Employee)
3.In sql server - using top keyword
SELECT TOP 1 salary FROM ( SELECT TOP 2 salary FROM employees ORDER BY salary DESC) AS emp
ORDER BY salary ASC
No comments:
Post a Comment