Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Problem 1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Write your MySQL query statement below

select score,dense_rank() over(order by score desc) as 'rank'
from scores;
9 changes: 9 additions & 0 deletions Problem 2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Write your MySQL query statement below
select
case
when id%2 =1 and id+1 <= (select count(*) from Seat) then id+1
when id%2 =0 then id-1
else id
end as id,student
from Seat
order by id asc;
8 changes: 8 additions & 0 deletions Problem 3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Write your MySQL query statement below
select id,
case
when p_id is null then 'Root'
when id in (select p_id from tree) then 'Inner'
else 'Leaf'
end as type
from tree ;
10 changes: 10 additions & 0 deletions Problem 4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Write your MySQL query statement below

with cte as(
select e.id,e.name as Employee,e.salary as Salary,d.name as Department,dense_rank() over(partition by d. name order by e.salary desc) as dens_col
from employee e
join Department d on e.departmentId = d.id)

select Department,Employee,Salary
from cte
where dens_col <=3;