├── Advanced Join ├── Placements.sql └── SQL PROJECT PLANNING.sql ├── Advanced Select ├── Binary Tree Nodes.sql ├── New Companies.sql ├── Occupations.sql ├── The PADS.sql └── Type of Triangle.sql ├── Aggregation ├── Average Population.sql ├── Japan Population.sql ├── Population Density Difference.sql ├── Revising Aggregations - Averages.sql ├── Revising Aggregations - The Count Function.sql ├── Revising Aggregations - The Sum Function.sql ├── The Blunder.sql ├── Top Earners.sql ├── Weather Observation Station 13.sql ├── Weather Observation Station 14.sql ├── Weather Observation Station 15.sql ├── Weather Observation Station 16.sql ├── Weather Observation Station 17.sql ├── Weather Observation Station 18.sql ├── Weather Observation Station 19.sql ├── Weather Observation Station 2.sql └── Weather Observation Station 20.sql ├── Basic Join ├── African Cities.sql ├── Asian Population.sql ├── Average Population of Each Continent.sql ├── Challenges.sql ├── Contest Leaderboard.sql ├── Ollivander's Inventory.sql ├── The Report.sql └── Top Competitors.sql ├── Basic Select ├── Employee-Names.sql ├── Employee-Salaries.sql ├── Higher-Than-75-Marks.sql ├── Japanese-Cities'-Attributes.sql ├── Japanese-Cities'-Names.sql ├── Revising-the-select-Query-1.sql ├── Revising-the-select-Query-2.sql ├── Select-All.sql ├── Select-By-ID.sql ├── Weather-Observation-Station-1.sql ├── Weather-Observation-Station-10.sql ├── Weather-Observation-Station-11.sql ├── Weather-Observation-Station-12.sql ├── Weather-Observation-Station-3.sql ├── Weather-Observation-Station-4.sql ├── Weather-Observation-Station-5.sql ├── Weather-Observation-Station-6.sql ├── Weather-Observation-Station-7.sql ├── Weather-Observation-Station-8.sql └── Weather-Observation-Station-9.sql └── README.md /Advanced Join/Placements.sql: -------------------------------------------------------------------------------- 1 | Select S.Name 2 | from Students S inner join Friends f 3 | on S.ID = f.ID 4 | inner join Packages p 5 | on f.ID = p.ID 6 | inner join Packages fp 7 | on f.Friend_ID = fp.ID 8 | where fp.Salary > p.Salary 9 | order by fp.Salary; 10 | -------------------------------------------------------------------------------- /Advanced Join/SQL PROJECT PLANNING.sql: -------------------------------------------------------------------------------- 1 | -- Author: @bratinkanrar 2 | SELECT s.Proj_Start_Date, min(e.Proj_End_Date) as Real_Proj_End_Date 3 | FROM 4 | (SELECT Start_Date as Proj_Start_Date FROM Projects WHERE Start_Date NOT IN (SELECT End_Date FROM Projects)) s, 5 | (SELECT End_Date as Proj_End_Date FROM Projects WHERE End_Date NOT IN (SELECT Start_Date FROM Projects)) e 6 | WHERE s.Proj_Start_Date < e.Proj_End_Date 7 | GROUP BY s.Proj_Start_Date 8 | ORDER BY DATEDIFF(min(e.Proj_End_Date), s.Proj_Start_Date) ASC, s.Proj_Start_Date ASC; 9 | -------------------------------------------------------------------------------- /Advanced Select/Binary Tree Nodes.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | SELECT BT.N, 3 | CASE 4 | WHEN BT.P IS NULL THEN 'Root' 5 | WHEN EXISTS (SELECT B.P FROM BST B WHERE B.P = BT.N) THEN 'Inner' 6 | ELSE 'Leaf' 7 | END 8 | FROM BST AS BT 9 | ORDER BY BT.N -------------------------------------------------------------------------------- /Advanced Select/New Companies.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | SELECT c.company_code,c.founder, 3 | count(distinct lm.lead_manager_code), 4 | count(distinct sm.senior_manager_code), 5 | count(distinct m.manager_code), 6 | count(distinct e.employee_code) 7 | FROM Company c, Lead_Manager lm, Senior_Manager sm, Manager m, Employee e 8 | WHERE 9 | c.company_code=lm.company_code AND 10 | lm.lead_manager_code=sm.lead_manager_code AND 11 | sm.senior_manager_code=m.senior_manager_code AND 12 | m.manager_code=e.manager_code 13 | GROUP BY c.company_code,c.founder 14 | ORDER BY c.company_code ASC -------------------------------------------------------------------------------- /Advanced Select/Occupations.sql: -------------------------------------------------------------------------------- 1 | -- Contributor: Abhishek Srivastava 2 | SELECT 3 | MAX(CASE WHEN Occupation = 'Doctor' THEN Name END) AS Doctor, 4 | MAX(CASE WHEN Occupation = 'Professor' THEN Name END) AS Professor, 5 | MAX(CASE WHEN Occupation = 'Singer' THEN Name END) AS Singer, 6 | MAX(CASE WHEN Occupation = 'Actor' THEN Name END) AS Actor 7 | FROM ( 8 | SELECT 9 | Name, 10 | Occupation, 11 | ROW_NUMBER() OVER (PARTITION BY Occupation ORDER BY Name) AS rn 12 | FROM OCCUPATIONS 13 | ) AS sub 14 | GROUP BY rn; 15 | 16 | -------------------------------------------------------------------------------- /Advanced Select/The PADS.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select concat(name,'(',substring(Occupation,1,1),')') as Name 3 | from occupations 4 | order by Name; 5 | Select concat ('There are a total of ', count(occupation),' ', lower(occupation),'s.') as totals 6 | from occupations 7 | group by occupation 8 | order by totals -------------------------------------------------------------------------------- /Advanced Select/Type of Triangle.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | Select 3 | CASE 4 | when A + B <= C or A + C <= B or B + C <= A then "Not A Triangle" 5 | when A = B and B = C then "Equilateral" 6 | when A = B or A = C or B = C then "Isosceles" 7 | else "Scalene" 8 | end as triangle_sides 9 | from TRIANGLES 10 | -------------------------------------------------------------------------------- /Aggregation/Average Population.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | SELECT FLOOR(AVG(POPULATION)) 3 | FROM CITY -------------------------------------------------------------------------------- /Aggregation/Japan Population.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | SELECT SUM(POPULATION) 3 | FROM CITY 4 | WHERE COUNTRYCODE ='JPN' -------------------------------------------------------------------------------- /Aggregation/Population Density Difference.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | SELECT MAX(POPULATION) - MIN(POPULATION) 3 | FROM CITY -------------------------------------------------------------------------------- /Aggregation/Revising Aggregations - Averages.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | SELECT AVG(POPULATION) 3 | FROM CITY 4 | WHERE DISTRICT ='California' 5 | -------------------------------------------------------------------------------- /Aggregation/Revising Aggregations - The Count Function.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | SELECT COUNT(*) FROM CITY WHERE POPULATION > 100000 -------------------------------------------------------------------------------- /Aggregation/Revising Aggregations - The Sum Function.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | SELECT SUM(POPULATION) 3 | FROM CITY 4 | WHERE DISTRICT = 'California' 5 | -------------------------------------------------------------------------------- /Aggregation/The Blunder.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | SELECT CEIL(AVG(Salary)-AVG(REPLACE(Salary,'0',''))) 3 | FROM EMPLOYEES -------------------------------------------------------------------------------- /Aggregation/Top Earners.sql: -------------------------------------------------------------------------------- 1 | SELECT MONTHS*SALARY AS earnings, COUNT(*) 2 | FROM employee 3 | GROUP BY earnings 4 | ORDER BY earnings DESC 5 | LIMIT 1; -------------------------------------------------------------------------------- /Aggregation/Weather Observation Station 13.sql: -------------------------------------------------------------------------------- 1 | select Round(sum(LAT_N),4) 2 | from STATION 3 | where LAT_N > 38.7880 and LAT_N < 137.2345; -------------------------------------------------------------------------------- /Aggregation/Weather Observation Station 14.sql: -------------------------------------------------------------------------------- 1 | select Round(max(LAT_N),4) 2 | from STATION 3 | where LAT_N < 137.2345; -------------------------------------------------------------------------------- /Aggregation/Weather Observation Station 15.sql: -------------------------------------------------------------------------------- 1 | select Round(LONG_W,4) 2 | from STATION 3 | where LAT_N = (Select Max(LAT_N)from STATION where LAT_N < 137.2345); -------------------------------------------------------------------------------- /Aggregation/Weather Observation Station 16.sql: -------------------------------------------------------------------------------- 1 | select Round(min(LAT_N),4) 2 | from STATION 3 | where LAT_N > 38.7780; -------------------------------------------------------------------------------- /Aggregation/Weather Observation Station 17.sql: -------------------------------------------------------------------------------- 1 | select Round(LONG_W,4) 2 | from STATION 3 | where LAT_N = ( 4 | select MIN(LAT_N) 5 | from STATION 6 | where LAT_N > 38.7780); -------------------------------------------------------------------------------- /Aggregation/Weather Observation Station 18.sql: -------------------------------------------------------------------------------- 1 | select Round(ABS(MIN(LAT_N) - MAX(LAT_N)) + ABS(MIN(LONG_W) - MAX(LONG_W)),4) 2 | FROM STATION; 3 | 4 | -------------------------------------------------------------------------------- /Aggregation/Weather Observation Station 19.sql: -------------------------------------------------------------------------------- 1 | SELECT ROUND(SQRT(POWER(MAX(LAT_N)-MIN(LAT_N),2)+POWER(MAX(LONG_W)-MIN(LONG_W),2)),4) 2 | FROM STATION; -------------------------------------------------------------------------------- /Aggregation/Weather Observation Station 2.sql: -------------------------------------------------------------------------------- 1 | SELECT ROUND(SUM(LAT_N),2),ROUND(SUM(LONG_W),2) 2 | FROM STATION; -------------------------------------------------------------------------------- /Aggregation/Weather Observation Station 20.sql: -------------------------------------------------------------------------------- 1 | SELECT Round(st.lat_n, 4) 2 | FROM station AS st 3 | WHERE (SELECT Count(lat_n) FROM station WHERE lat_n < st.lat_n) = (SELECT Count(lat_n) FROM station WHERE lat_n > st.lat_n); 4 | -------------------------------------------------------------------------------- /Basic Join/African Cities.sql: -------------------------------------------------------------------------------- 1 | select city.name from city join country on city.countrycode = country.code where country.continent = 'Africa'; -------------------------------------------------------------------------------- /Basic Join/Asian Population.sql: -------------------------------------------------------------------------------- 1 | select sum(city.population) from country left join city on country.code = city.countrycode where country.continent = 'Asia' -------------------------------------------------------------------------------- /Basic Join/Average Population of Each Continent.sql: -------------------------------------------------------------------------------- 1 | select country.continent, floor(avg(city.population)) from country join city on city.countrycode = country.code group by country.continent; -------------------------------------------------------------------------------- /Basic Join/Challenges.sql: -------------------------------------------------------------------------------- 1 | -- Use HAVING instead of WHERE since we have to filter on groups 2 | -- Split the total number of counts into 2 pieces 3 | -- First piece will be the largest number 4 | -- Second piece will be the number which doesn't repeat (Unique) or is available once 5 | 6 | select H.hacker_id, H.name, count(C.challenge_id) as total_count 7 | from Hackers H join Challenges C 8 | on H.hacker_id = C.hacker_id 9 | group by H.hacker_id, H.name 10 | having total_count = 11 | ( 12 | select count(temp1.challenge_id) as max_count 13 | from challenges temp1 14 | group by temp1.hacker_id 15 | order by max_count desc 16 | limit 1 17 | ) 18 | or total_count in 19 | ( 20 | select distinct other_counts from ( 21 | select H2.hacker_id, H2.name, count(C2.challenge_id) as other_counts 22 | from Hackers H2 join Challenges C2 23 | on H2.hacker_id = C2.hacker_id 24 | group by H2.hacker_id, H2.name 25 | ) temp2 26 | group by other_counts 27 | having count(other_counts) =1) 28 | order by total_count desc, H.hacker_id -------------------------------------------------------------------------------- /Basic Join/Contest Leaderboard.sql: -------------------------------------------------------------------------------- 1 | SELECT h.hacker_id, h.name, SUM(MAX_SCORE.t1) as total_score 2 | FROM Hackers h inner join 3 | ( 4 | SELECT MAX(s.score) as t1, s.hacker_id 5 | FROM Submissions s 6 | GROUP BY s.challenge_id, s.hacker_id 7 | HAVING t1 > 0 8 | ) AS MAX_SCORE 9 | ON h.hacker_id = MAX_SCORE.hacker_id 10 | GROUP BY h.hacker_id, h.name 11 | ORDER BY total_score DESC, hacker_id ASC 12 | -------------------------------------------------------------------------------- /Basic Join/Ollivander's Inventory.sql: -------------------------------------------------------------------------------- 1 | SELECT a.id, 2 | b.age, 3 | a.coins_needed, 4 | a.power 5 | FROM wands a 6 | JOIN wands_property b 7 | ON a.code = b.code 8 | WHERE b.is_evil = 0 9 | AND a.coins_needed = (SELECT Min(a1.coins_needed) 10 | FROM wands a1 11 | JOIN wands_property b1 12 | ON a1.code = b1.code 13 | WHERE b.age = b1.age 14 | AND a.power = a1.power) 15 | ORDER BY a.power DESC, 16 | b.age DESC; -------------------------------------------------------------------------------- /Basic Join/The Report.sql: -------------------------------------------------------------------------------- 1 | SELECT CASE 2 | WHEN G.grade > 7 THEN S.name 3 | ELSE NULL 4 | end AS names, 5 | G.grade, 6 | S.marks 7 | FROM students S 8 | JOIN grades G 9 | ON S.marks BETWEEN G.min_mark AND G.max_mark 10 | ORDER BY G.grade DESC, 11 | names ASC, 12 | S.marks ASC; -------------------------------------------------------------------------------- /Basic Join/Top Competitors.sql: -------------------------------------------------------------------------------- 1 | SELECT H.hacker_id, 2 | H.name 3 | FROM submissions S 4 | JOIN challenges C 5 | ON S.challenge_id = C.challenge_id 6 | JOIN difficulty D 7 | ON C.difficulty_level = D.difficulty_level 8 | JOIN hackers H 9 | ON S.hacker_id = H.hacker_id 10 | AND S.score = D.score 11 | GROUP BY H.hacker_id, 12 | H.name 13 | HAVING Count(S.hacker_id) > 1 14 | ORDER BY Count(S.hacker_id) DESC, 15 | S.hacker_id ASC; -------------------------------------------------------------------------------- /Basic Select/Employee-Names.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select name from employee order by name; -------------------------------------------------------------------------------- /Basic Select/Employee-Salaries.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select name from employee where salary > 2000 and months <10 order By employee_id; -------------------------------------------------------------------------------- /Basic Select/Higher-Than-75-Marks.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select name from students where marks > 75 order by right(name,3),id asc; 3 | -------------------------------------------------------------------------------- /Basic Select/Japanese-Cities'-Attributes.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select * from city where countrycode="JPN"; -------------------------------------------------------------------------------- /Basic Select/Japanese-Cities'-Names.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select name from city where CountryCode="JPN"; -------------------------------------------------------------------------------- /Basic Select/Revising-the-select-Query-1.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | SELECT * FROM CITY WHERE population > 100000 AND Countrycode ="USA"; 3 | -------------------------------------------------------------------------------- /Basic Select/Revising-the-select-Query-2.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | Select name from city where population > 120000 and Countrycode = "USA"; -------------------------------------------------------------------------------- /Basic Select/Select-All.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | Select * from city -------------------------------------------------------------------------------- /Basic Select/Select-By-ID.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select * from city where ID=1661; -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-1.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select city,State from station; 3 | -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-10.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select distinct(city) from station where 3 | city not like "%a" and 4 | city not like "%e" and 5 | city not like "%i" and 6 | city not like "%o" and 7 | city not like "%u"; 8 | 9 | -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-11.sql: -------------------------------------------------------------------------------- 1 | select distinct city from station where left(city,1) not in('a','e','i','o','u') or right(city,1) not in('a','e','i','o','u'); 2 | -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-12.sql: -------------------------------------------------------------------------------- 1 | select distinct city from station where left(city,1) not in('a','e','i','o','u') and right(city,1) not in('a','e','i','o','u'); 2 | -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-3.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | Select distinct city from station where ID%2=0; -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-4.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select count(city) - count(distinct city) from station; 3 | -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-5.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select city,length(city) from station order By length(city) asc, city asc limit 1; 3 | select distinct(City),length(city) from station order by length(city) desc, city asc limit 1; -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-6.sql: -------------------------------------------------------------------------------- 1 | # Author: Thomas George Thomas 2 | select distinct(city) from station where 3 | city like "a%" or 4 | city like "e%" or 5 | city like "i%" or 6 | city like "o%" or 7 | city like "u%"; 8 | 9 | # this works faster and better 10 | select distinct city from station where left(city,1) in('a','e','i','o','u') 11 | -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-7.sql: -------------------------------------------------------------------------------- 1 | select distinct city from station where right(city,1) in('a','e','i','o','u') 2 | -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-8.sql: -------------------------------------------------------------------------------- 1 | select distinct city from station where left(city,1) in('a','e','i','o','u') and right(city,1) in('a','e','i','o','u') 2 | -------------------------------------------------------------------------------- /Basic Select/Weather-Observation-Station-9.sql: -------------------------------------------------------------------------------- 1 | select distinct city from station where left(city,1) not in('a','e','i','o','u') 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
3 | 4 | 5 |
6 |
7 |

8 | 9 | ## Description 10 | The solutions of all the SQL challenges for all easy, medium and hard challenges on HackerRank executed on MySQL environment compiled with helpful Resources & references related to the challenges. 11 | 12 | ## Domains 13 | 14 | ### Basic Select Challenges 15 | 16 | | Number | Challenges | Solutions | 17 | |:------:|------------|:---------:| 18 | | 1 | [Revising the Select Query I](https://www.hackerrank.com/challenges/revising-the-select-query/problem) | [SQL](Basic%20Select/Revising-the-select-Query-1.sql) 19 | | 2 | [Revising the Select Query II](https://www.hackerrank.com/challenges/revising-the-select-query-2/problem) | [SQL](Basic%20Select/Revising-the-select-Query-2.sql) 20 | | 3 | [Select All](https://www.hackerrank.com/challenges/select-all-sql/problem) | [SQL](Basic%20Select/Select-All.sql) 21 | | 4 | [Select By ID](https://www.hackerrank.com/challenges/select-by-id/problem) | [SQL](Basic%20Select/Select-By-ID.sql) 22 | | 5 | [Japanese Cities' Attributes](https://www.hackerrank.com/challenges/japanese-cities-attributes/problem) | [SQL](Basic%20Select/Japanese-Cities'-Attributes.sql) 23 | | 6 | [Japanese Cities' Names](https://www.hackerrank.com/challenges/japanese-cities-name/problem) | [SQL](Basic%20Select/Japanese-Cities'-Names.sql) 24 | | 7 | [Weather Observation Station 1](https://www.hackerrank.com/challenges/weather-observation-station-1/problem) | [SQL](Basic%20Select/Weather-Observation-Station-1.sql) 25 | | 8 | [Weather Observation Station 3](https://www.hackerrank.com/challenges/weather-observation-station-3/problem) | [SQL](Basic%20Select/Weather-Observation-Station-3.sql) 26 | | 9 | [Weather Observation Station 4](https://www.hackerrank.com/challenges/weather-observation-station-4/problem) | [SQL](Basic%20Select/Weather-Observation-Station-4.sql) 27 | | 10| [Weather Observation Station 5](https://www.hackerrank.com/challenges/weather-observation-station-5/problem) | [SQL](Basic%20Select/Weather-Observation-Station-5.sql) 28 | | 11| [Weather Observation Station 6](https://www.hackerrank.com/challenges/weather-observation-station-6/problem) | [SQL](Basic%20Select/Weather-Observation-Station-6.sql) 29 | | 12| [Weather Observation Station 7](https://www.hackerrank.com/challenges/weather-observation-station-7/problem) | [SQL](Basic%20Select/Weather-Observation-Station-7.sql) 30 | | 13| [Weather Observation Station 8](https://www.hackerrank.com/challenges/weather-observation-station-8/problem) | [SQL](Basic%20Select/Weather-Observation-Station-8.sql) 31 | | 14| [Weather Observation Station 9](https://www.hackerrank.com/challenges/weather-observation-station-9/problem) | [SQL](Basic%20Select/Weather-Observation-Station-9.sql) 32 | | 15| [Weather Observation Station 10](https://www.hackerrank.com/challenges/weather-observation-station-10/problem) | [SQL](Basic%20Select/Weather-Observation-Station-10.sql) 33 | | 16| [Weather Observation Station 11](https://www.hackerrank.com/challenges/weather-observation-station-11/problem) | [SQL](Basic%20Select/Weather-Observation-Station-11.sql) 34 | | 17| [Weather Observation Station 12](https://www.hackerrank.com/challenges/weather-observation-station-12/problem) | [SQL](Basic%20Select/Weather-Observation-Station-12.sql) 35 | | 18| [Higher Than 75 Marks](https://www.hackerrank.com/challenges/more-than-75-marks/problem) | [SQL](Basic%20Select/Higher-Than-75-Marks.sql) 36 | | 19| [Employee Names](https://www.hackerrank.com/challenges/name-of-employees/problem) | [SQL](Basic%20Select/Employee-Names.sql) 37 | | 20| [Employee Salaries](https://www.hackerrank.com/challenges/salary-of-employees/problem) | [SQL](Basic%20Select/Employee-Salaries.sql) 38 | 39 | ### Advanced Select Challenges 40 | 41 | | Number | Challenges | Solutions | 42 | |:------:|------------|:---------:| 43 | | 1 |[Type of Triangle](https://www.hackerrank.com/challenges/what-type-of-triangle/problem) | [SQL](Advanced%20Select/Type%20of%20Triangle.sql) | 44 | | 2 |[The PADS](https://www.hackerrank.com/challenges/the-pads/problem) | [SQL](Advanced%20Select/The%20PADS.sql) | 45 | | 3 |[Occupations](https://www.hackerrank.com/challenges/occupations/problem) | [SQL](Advanced%20Select/Occupations.sql) | 46 | | 4 |[Binary Tree Nodes](https://www.hackerrank.com/challenges/binary-search-tree-1/problem) | [SQL](Advanced%20Select/Binary%20Tree%20Nodes.sql)| 47 | | 5 |[New Companies](https://www.hackerrank.com/challenges/the-company/problem) | [SQL](Advanced%20Select/New%20Companies.sql) | 48 | 49 | 50 | 51 | ### Aggregation Challenges 52 | 53 | | Number | Challenges | Solutions | 54 | |:------:|------------|:---------:| 55 | | 1 | [Revising Aggregations - The Count Function](https://www.hackerrank.com/challenges/revising-aggregations-the-count-function/problem) | [SQL](Aggregation/Revising%20Aggregations%20-%20The%20Count%20Function.sql) | 56 | | 2 | [Revising Aggregations - The Sum Function](https://www.hackerrank.com/challenges/revising-aggregations-sum/problem) | [SQL](Aggregation/Revising%20Aggregations%20-%20The%20Sum%20Function.sql) | 57 | | 3 | [Revising Aggregations - Averages](https://www.hackerrank.com/challenges/revising-aggregations-the-average-function/problem) | [SQL](Aggregation/Revising%20Aggregations%20-%20Averages.sql) | 58 | | 4 | [Average Population](https://www.hackerrank.com/challenges/average-population/problem) | [SQL](Aggregation/Average%20Population.sql) | 59 | | 5 | [Japan Population](https://www.hackerrank.com/challenges/japan-population/problem) | [SQL](Aggregation/Japan%20Population.sql) | 60 | | 6 | [Population Density Difference](https://www.hackerrank.com/challenges/population-density-difference/problem) | [SQL](Aggregation/Population%20Density%20Difference.sql) | 61 | | 7 | [The Blunder](https://www.hackerrank.com/challenges/the-blunder/problem) | [SQL](Aggregation/The%20Blunder.sql) 62 | | 8 | [Top Earners](https://www.hackerrank.com/challenges/earnings-of-employees/problem) | [SQL](Aggregation/Top%20Earners.sql) | 63 | | 9 | [Weather Observation Station 2](https://www.hackerrank.com/challenges/weather-observation-station-2/problem) | [SQL](Aggregation/Weather%20Observation%20Station%202.sql) | 64 | | 10| [Weather Observation Station 13](https://www.hackerrank.com/challenges/weather-observation-station-13/problem) | [SQL](Aggregation/Weather%20Observation%20Station%2013.sql) | 65 | | 11| [Weather Observation Station 14](https://www.hackerrank.com/challenges/weather-observation-station-14/problem) | [SQL](Aggregation/Weather%20Observation%20Station%2014.sql) | 66 | | 12| [Weather Observation Station 15](https://www.hackerrank.com/challenges/weather-observation-station-15/problem) | [SQL](Aggregation/Weather%20Observation%20Station%2015.sql) | 67 | | 13| [Weather Observation Station 16](https://www.hackerrank.com/challenges/weather-observation-station-16/problem) | [SQL](Aggregation/Weather%20Observation%20Station%2016.sql) | 68 | | 14| [Weather Observation Station 17](https://www.hackerrank.com/challenges/weather-observation-station-17/problem) | [SQL](Aggregation/Weather%20Observation%20Station%2017.sql) | 69 | | 15| [Weather Observation Station 18](https://www.hackerrank.com/challenges/weather-observation-station-18/problem) | [SQL](Aggregation/Weather%20Observation%20Station%2018.sql) | 70 | | 16| [Weather Observation Station 19](https://www.hackerrank.com/challenges/weather-observation-station-19/problem) | [SQL](Aggregation/Weather%20Observation%20Station%2019.sql) | 71 | | 17| [Weather Observation Station 20](https://www.hackerrank.com/challenges/weather-observation-station-20/problem) | [SQL](Aggregation/Weather%20Observation%20Station%2020.sql) | 72 | 73 | 74 | ### Basic Join 75 | 76 | | Number | Challenges | Solutions | 77 | |:------:|------------|:---------:| 78 | | 1 | [Asian Population](https://www.hackerrank.com/challenges/asian-population/problem) | [SQL](Basic%20Join/Asian%20Population.sql) | 79 | | 2 | [African Cities](https://www.hackerrank.com/challenges/african-cities/problem) | [SQL](Basic%20Join/African%20Cities.sql) | 80 | | 3 | [Average Population of Each Continent](https://www.hackerrank.com/challenges/average-population-of-each-continent/problem) | [SQL](Basic%20Join/Average%20Population%20of%20Each%20Continent.sql) | 81 | | 4 | [The Report](https://www.hackerrank.com/challenges/the-report/submissions/code/94188063) | [SQL](Basic%20Join/The%20Report.sql) | 82 | | 5 | [Top Competitors](https://www.hackerrank.com/challenges/full-score/problem) | [SQL](Basic%20Join/Top%20Competitors.sql) | 83 | | 6 | [Ollivander's Inventory](https://www.hackerrank.com/challenges/harry-potter-and-wands/problem) | [SQL](Basic%20Join/Ollivander's%20Inventory.sql) | 84 | | 7 | [Challenges](https://www.hackerrank.com/challenges/challenges/problem) | [SQL](Basic%20Join/Challenges.sql) | 85 | | 8 | [Contest Leaderboard](https://www.hackerrank.com/challenges/contest-leaderboard/problem) | [SQL](/Basic%20Join/Contest%20Leaderboard.sql) | 86 | 87 | ### Advanced Join 88 | 89 | | Number | Challenges | Solutions | 90 | |:------:|:----------------------------------------------------------------------------------:|:--------------------------------------------------:| 91 | | 1 | [SQL Project Planning](https://www.hackerrank.com/challenges/sql-projects/problem) | [SQL](ADVANCE%20JOIN/SQL%20PROJECT%20PLANNING.sql) | 92 | | 2 | [Placements](https://www.hackerrank.com/challenges/placements/problem) | [SQL](ADVANCE%20JOIN/Placements.sql) | 93 | 94 | ## References 95 | 96 | - [Instant SQL Formatter](http://www.dpriver.com/pp/sqlformat.htm) 97 | - [Variables in MySQL](https://stackoverflow.com/a/11754790) 98 | - [Median in MySQL](https://stackoverflow.com/a/7263925) 99 | --------------------------------------------------------------------------------