Friday, April 15, 2016

SQL Interview Questions

i ask this. if u have a table with city and population columns. how do u find the 7th largest populated city?
did u get a chance to use HAVING anywhere?
if so, how did u use it?

SELECT * FROM (
SELECT EmployeeID, Salary, RANK() over (order by Salary DESC) RANKING
from Employee
)
WHERE ranking = N;

SELECT depname, empno, salary, avg(salary) OVER (PARTITION BY depname) FROM empsalary;

SELECT depname, empno, salary, rank() OVER (PARTITION BY depname ORDER BY salary DESC) FROM empsalary;



CASE WHEN

CAST


a pair of photo


select a.pi as pi1,
       b.pi as pi2
from
(select pi, count(*)
from save
group by pair
having count(*) > 100) a,
(select pi, count(*)
from save
group by pair
having count(*) > 100) b
where
a.pi < b.pi







No comments:

Post a Comment