조컴퓨터

hackerrank Top Earners 본문

HackerRank/SQL

hackerrank Top Earners

챠오위 2021. 1. 17. 16:24

 

1)

salary * months = earnings

 

1-1)

SELECT *, salary * months AS earnings

FROM Employee

 

위를 포함한 106줄 출력

 

 

1-2) 

SELECT salary * months AS earnings

FROM Employee

GROUP BY earnings

 

 

 

1-3)

SELECT salary * months AS earnings

FROM Employee

GROUP BY earnings

ORDER BY earnings

 

ASC

 

 

1-4)

SELECT salary * months AS earnings

FROM Employee

GROUP BY earnings

ORDER BY earnings DESC

 

DESC

 

 

1-5)

SELECT salary * months AS earnings

FROM Employee

GROUP BY earnings

ORDER BY earnings DESC

LIMIT 1;

 

 

 

2) 갯수 출력 

COUNT(*)

 

2-1)

SELECT salary * months AS earnings, COUNT(*)

FROM Employee

GROUP BY earnings

ORDER BY earnings DESC

LIMIT 1;

 

 

 

SUCCESS!

 

 

 

 

 

'HackerRank > SQL' 카테고리의 다른 글

hackerrank Weather Observation Station 6  (0) 2021.01.31
hackerrank Weather Observation Station 5  (0) 2021.01.31
hackerrank Weather Observation Station 3  (0) 2021.01.30
hackerrank Symmetric Pairs  (0) 2021.01.18
hackerrank Type of Triangle  (0) 2021.01.18