Skip to content

Commit

Permalink
๐Ÿ”€ 22.01.12 - ์˜ค๋Š˜์˜ SQL #82
Browse files Browse the repository at this point in the history
22.01.12 - ์˜ค๋Š˜์˜ SQL
  • Loading branch information
mildsalmon committed Jan 12, 2022
2 parents f6bfc50 + d6df5aa commit 084505c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 2. SQL/2. HackerRank/1. Easy/Top Earners.sql
@@ -0,0 +1,17 @@
/*
Date : 2022.01.12
Update : 2022.01.12
Source : Top Earners.sql
Purpose : count / ์„œ๋ธŒ์ฟผ๋ฆฌ
url : https://www.hackerrank.com/challenges/earnings-of-employees/problem?isFullScreen=true
Author : ๊น€ํ•™์ง„ (mildsalmon)
Email : mildsalmon@gamil.com
*/

-- count๋ฅผ ์‚ฌ์šฉํ• ๋•Œ ๋‹ค๋ฅธ ์ ˆ์ด ์žˆ์œผ๋ฉด ๋‹ค๋ฅธ ์ ˆ๋“ค์„ group by๋กœ ๋ฌถ์–ด์ค˜์•ผํ•œ๋‹ค.
SELECT a.months*a.salary, COUNT(a.months*a.salary)
FROM employee a
WHERE a.months*a.salary = (SELECT MAX(b.months*b.salary)
FROM employee b)
GROUP BY a.months*a.salary
;
14 changes: 14 additions & 0 deletions 2. SQL/2. HackerRank/1. Easy/Weather Observation Station 13.sql
@@ -0,0 +1,14 @@
/*
Date : 2022.01.12
Update : 2022.01.12
Source : Weather Observation Station 13.sql
Purpose : TRUNC / BETWEEN
url : https://www.hackerrank.com/challenges/weather-observation-station-13/problem?isFullScreen=true
Author : ๊น€ํ•™์ง„ (mildsalmon)
Email : mildsalmon@gamil.com
*/

SELECT TRUNC(SUM(LAT_N), 4)
FROM STATION
WHERE LAT_N BETWEEN 38.7880 AND 137.2345
;
13 changes: 13 additions & 0 deletions 2. SQL/2. HackerRank/1. Easy/Weather Observation Station 2.sql
@@ -0,0 +1,13 @@
/*
Date : 2022.01.12
Update : 2022.01.12
Source : Weather Observation Station 2.sql
Purpose : ROUND / SUM
url : https://www.hackerrank.com/challenges/weather-observation-station-2/problem?isFullScreen=true
Author : ๊น€ํ•™์ง„ (mildsalmon)
Email : mildsalmon@gamil.com
*/

SELECT ROUND(SUM(LAT_N), 2), ROUND(SUM(LONG_W), 2)
FROM station
;

0 comments on commit 084505c

Please sign in to comment.