mysql

SQL 문제풀이

[해커랭크 SQL] Basic Join - Average Population of Each Continent

❓ Question https://www.hackerrank.com/challenges/average-population-of-each-continent Average Population of Each Continent | HackerRank Query the names of all continents and their respective city populations, rounded down to the nearest integer. www.hackerrank.com ❗ Answer SELECT country.continent, FLOOR(AVG(city.population)) FROM city INNER JOIN country ON city.countrycode = country.code GROUP ..

SQL 문제풀이

[해커랭크 SQL] Basic Join - African Cities

❓ Question https://www.hackerrank.com/challenges/african-cities African Cities | HackerRank Query the names of all cities on the continent 'Africa'. www.hackerrank.com ❗ Answer SELECT city.name FROM city INNER JOIN country ON city.countrycode = country.code WHERE country.continent = 'Africa'; 📌 Discussion join 후 조건에 해당하는 레코드만 추출

SQL 문제풀이

[해커랭크 SQL] Basic Join - Population Census

❓ Question https://www.hackerrank.com/challenges/asian-population Population Census | HackerRank Query the sum of the populations of all cities on the continent 'Asia'. www.hackerrank.com ❗ Answer SELECT SUM(city.population) FROM city INNER JOIN country ON city.countrycode = country.code WHERE country.continent = 'ASIA'; 📌 Discussion INNER JOIN 후 조건을 걸어서 모든 인구를 합해주었다.

SQL 문제풀이

[해커랭크 SQL] Advanced Select - The PADS

❓ Question https://www.hackerrank.com/challenges/the-pads The PADS | HackerRank Query the name and abbreviated occupation for each person in OCCUPATIONS. www.hackerrank.com ❗ Answer SELECT CONCAT(name,'(',LEFT(occupation,1),')') FROM occupations ORDER BY name; SELECT CONCAT('There are a total of ' , a.cnt, ' ', LOWER(a.occupation), IF(cnt>=2,'s.','.')) FROM (SELECT occupation, COUNT(*) cnt FROM ..

SQL 문제풀이

[해커랭크 SQL] Advanced Select - Type of Triangle

❓ Question https://www.hackerrank.com/challenges/what-type-of-triangle Type of Triangle | HackerRank Query a triangle's type based on its side lengths. www.hackerrank.com ❗ Answer SELECT (CASE WHEN a>=b+c OR b>=c+a OR c>=a+b THEN 'Not A Triangle' WHEN a=b AND b=c THEN 'Equilateral' WHEN (a=b AND b!=c) OR (b=c AND c!=a) OR (c=a AND a!=b) THEN 'Isosceles' ELSE 'Scalene' END) FROM triangles; 📌 Disc..

SQL 문제풀이

[해커랭크 SQL] Basic Select - Employee Salaries

❓ Question https://www.hackerrank.com/challenges/salary-of-employees Employee Salaries | HackerRank Print the names of employees who earn more than $2000 per month and have worked at the company for less than 10 months. www.hackerrank.com ❗ Answer SELECT name FROM employee WHERE salary > 2000 AND months < 10 ORDER BY employee_id; 📌 Discussion - WHERE 에서 salary와 months에서 두가지 조건을 걸어줌

SQL 문제풀이

[해커랭크 SQL] Basic Select - Employee Names

❓ Question https://www.hackerrank.com/challenges/name-of-employees Employee Names | HackerRank Print employee names. www.hackerrank.com ❗ Answer SELECT name FROM employee ORDER BY name; 📌 Discussion - ORDER BY에서 이름 순으로 정렬

SQL 문제풀이

[해커랭크 SQL] Basic Select - Higher Than 75 Marks

❓ Question https://www.hackerrank.com/challenges/more-than-75-marks Higher Than 75 Marks | HackerRank Query the names of students scoring higher than 75 Marks. Sort the output by the LAST three characters of each name. www.hackerrank.com ❗ Answer SELECT name FROM students WHERE marks > 75 ORDER BY RIGHT(name,3), id; 📌 Discussion - WHERE에 조건을 걸어주고 ORDER BY에서 이름의 오른쪽 세글자 순으로 정렬해줌

냄비짱
'mysql' 태그의 글 목록 (3 Page)