https://school.programmers.co.kr/learn/courses/30/lessons/151136
SELECT ROUND(AVG(DAILY_FEE), 0) AS AVERAGE_FEE
https://school.programmers.co.kr/learn/courses/30/lessons/131536
https://school.programmers.co.kr/learn/courses/30/lessons/59404
https://school.programmers.co.kr/learn/courses/30/lessons/59405
SELECT USER_ID, PRODUCT_ID
FROM ONLINE_SALE
GROUP BY USER_ID, PRODUCT_ID
HAVING COUNT(*) >= 2
ORDER BY USER_ID ASC, PRODUCT_ID DESC
https://school.programmers.co.kr/learn/courses/30/lessons/131535
YEAR(JOINED) = 2021
https://school.programmers.co.kr/learn/courses/30/lessons/132203
DATE_FORMAT(HIRE_YMD, '%Y-%m-%d')
https://school.programmers.co.kr/learn/courses/30/lessons/133025
FLAVOR IN (
SELECT FLAVOR
FROM ICECREAM_INFO
WHERE INGREDIENT_TYPE = 'fruit_based')
https://school.programmers.co.kr/learn/courses/30/lessons/131120
DATE_FORMAT(DATE_OF_BIRTH, '%Y-%m-%d') AS DATE_OF_BIRTH
MONTH(DATE_OF_BIRTH)
TLNO IS NOT NULL
https://school.programmers.co.kr/learn/courses/30/lessons/164673
AS CREATED_DATE (AS문에서는 R. CREATED_DATE 이런식으로 쓸 수 없음)
FROM USED_GOODS_BOARD B JOIN USED_GOODS_REPLY R ON B.BOARD_ID = R.BOARD_ID
WHERE DATE_FORMAT(B.CREATED_DATE, '%Y-%m') = '2022-10'
https://school.programmers.co.kr/learn/courses/30/lessons/131112
WHERE ADDRESS LIKE '강원도%'
https://school.programmers.co.kr/learn/courses/30/lessons/132201
COALESCE(TLNO, 'NONE') AS TLNO
https://school.programmers.co.kr/learn/courses/30/lessons/273711
문제 제대로 이해하자!
# JOIN문 사용법
SELECT 컬럼명
FROM 테이블1 별칭1
JOIN 테이블2 별칭2 ON 조건
ex)
SELECT it.ITEM_ID, it.ITEM_NAME, it.RARITY
FROM ITEM_INFO it JOIN ITEM_TREE tr on it.ITEM_ID = tr.ITEM_ID
https://school.programmers.co.kr/learn/courses/30/lessons/276013
WHERE 'Python' IN (SKILL_1, SKILL_2, SKILL_3)
https://school.programmers.co.kr/learn/courses/30/lessons/131697
SELECT MAX(PRICE) AS MAX_PRICE
https://school.programmers.co.kr/learn/courses/30/lessons/131115
WHERE PRICE = (
SELECT MAX(PRICE)
FROM FOOD_PRODUCT)
https://school.programmers.co.kr/learn/courses/30/lessons/59408
SELECT COUNT(DISTINCT NAME)
https://school.programmers.co.kr/learn/courses/30/lessons/151137
SELECT CAR_TYPE, COUNT(*) AS CARS
FROM CAR_RENTAL_COMPANY_CAR
WHERE OPTIONS LIKE '%가죽시트%' OR OPTIONS LIKE '%열선시트%' OR OPTIONS LIKE '%통풍시트%'
GROUP BY CAR_TYPE
ORDER BY CAR_TYPE ASC
https://school.programmers.co.kr/learn/courses/30/lessons/133026
JOIN문, SUM문 둘다 사용해볼 수 있는 좋은 문제
https://school.programmers.co.kr/learn/courses/30/lessons/132202
WHERE은 ORDER BY보다 앞에 있어야 한다..!
SELECT MCDP_CD AS 진료과코드, COUNT(MCDP_CD) AS 5월예약건수
FROM APPOINTMENT
WHERE DATE_FORMAT(APNT_YMD, '%Y-%m') = '2022-05'
GROUP BY MCDP_CD
ORDER BY 5월예약건수 ASC, MCDP_CD ASC
https://school.programmers.co.kr/learn/courses/30/lessons/131530
SELECT FLOOR(PRICE / 10000) * 10000 AS PRICE_GROUP, COUNT(*) AS PRODUCTS
FROM PRODUCT
GROUP BY PRICE_GROUP
ORDER BY PRICE_GROUP ASC
https://school.programmers.co.kr/learn/courses/30/lessons/293257
SELECT COUNT(I.FISH_TYPE) AS FISH_COUNT, N.FISH_NAME
FROM FISH_INFO I JOIN FISH_NAME_INFO N ON I.FISH_TYPE = N.FISH_TYPE
GROUP BY N.FISH_NAME
ORDER BY FISH_COUNT DESC
GROUP BY에 왜 I.FISH_TYPE이 아니라 N.FISH_NAME인지 고민해보자!