Skip to content

Instantly share code, notes, and snippets.

View Nader93's full-sized avatar
🎯
Focusing

Nader Naser Nader93

🎯
Focusing
View GitHub Profile
@Nader93
Nader93 / New Companies.sql
Created May 5, 2019 11:22
New Companies Hackerrank solution (two solutions)
SELECT company.company_code,company.founder,
count(distinct Lead_manager.lead_manager_code),
count(distinct Senior_manager.senior_manager_code),
count(distinct Manager.manager_code),count(distinct Employee.employee_code)
from company
INNER JOIN Lead_Manager
on company.company_code = Lead_Manager.company_code
INNER JOIN Senior_Manager
on company.company_code = Senior_Manager.company_code
@Nader93
Nader93 / Binary Tree Nodes.sql
Last active May 2, 2019 16:10
Binary Tree Nodes hackerrank (best solution)
select case
when p is null then concat(n, ' Root')
when n in (select distinct p from bst) then concat(n, ' Inner')
else concat(n, ' Leaf')
end
from bst
order by n asc
@Nader93
Nader93 / The PADS-hackerrank.sql
Last active May 2, 2019 07:03
The PADS hackerrank solution
select concat(name,"(",left(OCCUPATION,1),")")
from OCCUPATIONS
order by name asc;
select concat("There are a total of"," ",count(OCCUPATION)," ",LOWER(OCCUPATION),"s",".")
from OCCUPATIONS
group by OCCUPATION
order by count(OCCUPATION),OCCUPATION;