MySQL/문제풀이24 [LeetCode] Self JOIN : 181. Employees Earning More Than Their Managers 1. 문제 The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+-----------+ | Id | Name | Salary | ManagerId | +----+-------+--------+-----------+ | 1 | Joe | 70000 | 3 | | 2 | Henry | 80000 | 4 | | 3 | Sam | 60000 | NULL | | 4 | Max | 90000 | NULL | +----+-------+--------+-----------+ Given t.. 2021. 3. 15. [LeetCode] LEFT JOIN : 183. Customers Who Never Order 1. 문제 Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything. Table: Customers. +----+-------+ | Id | Name | +----+-------+ | 1 | Joe | | 2 | Henry | | 3 | Sam | | 4 | Max | +----+-------+ Table: Orders. +----+------------+ | Id | CustomerId | +----+------------+ | 1 | 3 | | 2 | 1 | +----+------------.. 2021. 3. 15. [HackerRank] INNER JOIN : Average Population of Each Continent 1. 문제 Given the CITY and COUNTRY tables, query the names of all the continents (COUNTRY.Continent) and their respective average city populations (CITY.Population) rounded down to the nearest integer. Note: CITY.CountryCode and COUNTRY.Code are matching key columns. Input Format The CITY and COUNTRY tables are described as follows: 2. 답 SELECT country.continent, FLOOR(AVG(city.population)) FROM c.. 2021. 3. 15. [HackerRank] INNER JOIN : Asian Population 1. 문제 Given the CITY and COUNTRY tables, query the sum of the populations of all cities where the CONTINENT is 'Asia'. Note: CITY.CountryCode and COUNTRY.Code are matching key columns. Input Format The CITY and COUNTRY tables are described as follows: 2. 답 SELECT SUM(city.population) FROM city INNER JOIN country ON city.countrycode = country.code where country.continent = 'Asia' 3. KEY POINT INN.. 2021. 3. 15. [HackerRank] INNER JOIN : African Cities 1. 문제 Given the CITY and COUNTRY tables, query the names of all cities where the CONTINENT is 'Africa'. Note: CITY.CountryCode and COUNTRY.Code are matching key columns. Input Format The CITY and COUNTRY tables are described as follows: 2. 답 SELECT city.name FROM city INNER JOIN country ON city.countrycode = country.code WHERE country.continent = 'Africa' 3. KEY POINT INNER JOIN : 양쪽 테이블에 모두 정보가.. 2021. 3. 15. [HackerRank] CASE : Type of Triangle 1. 문제 Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table: Equilateral: It's a triangle with 3 sides of equal length. Isosceles: It's a triangle with 2 sides of equal length. Scalene: It's a triangle with 3 sides of differing lengths. Not A Triangle: The given values of A, B, an.. 2021. 3. 15. 이전 1 2 3 4 다음