공부/PS ( SQL)
-
[HackerRank/Aggregation] Revising Aggregations - Average Population공부/PS ( SQL) 2022. 5. 18. 02:16
https://www.hackerrank.com/challenges/average-population/problem Average Population | HackerRank Query the average population of all cities, rounded down to the nearest integer. www.hackerrank.com 문제 풀이 SELECT ROUND(AVG(POPULATION)) FROM CITY 반올림 (ROUND) 사용법: ROUND(숫자, 반올림할 자릿수) 제거 (TRUNCATE) 사용법: TRUNCATE(숫자, 남길 자릿수(소수n째 자리)) 무조건 버림할 자릿수를 입력해야함 올림 (CEIL) 사용법: CEIL(숫자) 버림 (FLOOR) 사용법: FLOOR(숫자)
-
[HackerRank/Aggregation] Revising Aggregations - Averages공부/PS ( SQL) 2022. 5. 18. 02:10
https://www.hackerrank.com/challenges/revising-aggregations-the-average-function/problem Revising Aggregations - Averages | HackerRank Query the average population of all cities in the District of California. www.hackerrank.com 문제 풀이 SELECT AVG(POPULATION) FROM CITY WHERE DISTRICT LIKE 'California'
-
[HackerRank/Aggregation] Revising Aggregations - The Count Function공부/PS ( SQL) 2022. 5. 17. 01:19
https://www.hackerrank.com/challenges/revising-aggregations-the-count-function/problem Revising Aggregations - The Count Function | HackerRank Query the number of cities having populations larger than 100000. www.hackerrank.com 문제 풀이 SELECT COUNT(NAME) FROM CITY WHERE POPULATION > 100000
-
[HackerRank/Advanced Select] The PADS공부/PS ( SQL) 2022. 5. 16. 01:29
https://www.hackerrank.com/challenges/the-pads/problem The PADS | HackerRank Query the name and abbreviated occupation for each person in OCCUPATIONS. www.hackerrank.com 문제 풀이 SELECT CONCAT(Name, "(", LEFT(Occupation,1), ")") FROM OCCUPATIONS ORDER BY Name; SELECT CONCAT("There are a total of ", COUNT(occupation), " ", LOWER(Occupation), "s.") FROM OCCUPATIONS GROUP BY Occupation ORDER BY COUNT(..
-
[HackerRank/Advanced Select] Type of Triangle공부/PS ( SQL) 2022. 5. 16. 01:12
https://www.hackerrank.com/challenges/what-type-of-triangle/problem Type of Triangle | HackerRank Query a triangle's type based on its side lengths. www.hackerrank.com 문제 풀이 SELECT CASE WHEN A = B AND B = C THEN 'Equilateral' WHEN A >= B+C OR B >= A+C OR C >= A+B THEN 'Not A Triangle' WHEN A = B OR B = C OR C = A THEN 'Isosceles' ELSE 'Scalene' END FROM TRIANGLES; CASE문 SELECT CASE WHEN 조건 THEN ..
-
[HackerRank/Basic Select] Employee Salaries공부/PS ( SQL) 2022. 5. 16. 00:44
https://www.hackerrank.com/challenges/salary-of-employees/problem 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 문제 풀이 SELECT name FROM Employee WHERE salary > 2000 AND months < 10 ORDER BY employee_id
-
[HackerRank/Basic Select] Higher Than 75 Marks공부/PS ( SQL) 2022. 5. 16. 00:39
https://www.hackerrank.com/challenges/more-than-75-marks/problem 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 문제 풀이 SELECT Name FROM STUDENTS WHERE Marks > 75 ORDER BY SUBSTR(Name, -3), ID Name 문자열의 뒤 3글자를 정렬 기준으로 삼아야 함 SUBSTR("문자열", '시작 index', '길이') 또는 SUBSTRING("문자열", '..