TIL - 250205

오정수·2025년 2월 5일

TIL

목록 보기
41/78

리뷰 : 윈도우 함수를 다시 재검토하는 시간을 가졌다. 추가로 LIMIT와 함께 쓰이는 OFFSET에 대해 알게 되었다.

URL : https://datalemur.com/questions/total-drugs-sales

SELECT 
  manufacturer
  ,CONCAT('$',ROUND(SUM(total_sales)/1000000),' million')
FROM pharmacy_sales
GROUP BY 1
ORDER BY SUM(total_sales) DESC
;

URL : https://datalemur.com/questions/sql-second-highest-salary

SELECT
  salary
FROM (
SELECT salary
FROM employee
ORDER BY salary DESC
LIMIT 2
) a
ORDER BY salary
LIMIT 1
;
SELECT salary
FROM employee
ORDER BY salary DESC
LIMIT 1 OFFSET 1;
profile
안녕하세요 오정수입니다

0개의 댓글