SELECT(2) | MySQL
September 25, 2023
MySQL프로그래머스
SELECT ROUND(AVG(DAILY_FEE),0) AS AVERAGE_FEE
FROM CAR_RENTAL_COMPANY_CAR
GROUP BY CAR_TYPE
HAVING CAR_TYPE = 'SUV'
;
- ROUND(숫자값, 반올림할 자릿수)
- TRUNCATE(숫자값, 버릴 자릿수)
SELECT PT_NAME, PT_NO, GEND_CD, AGE, IFNULL(TLNO, 'NONE') AS TLNO
FROM PATIENT
WHERE (AGE <= 12) AND (GEND_CD = 'W')
ORDER BY AGE DESC, PT_NAME ASC
;
SELECT MEMBER_ID, MEMBER_NAME, GENDER, DATE_FORMAT(DATE_OF_BIRTH, '%Y-%m-%d')
FROM MEMBER_PROFILE
WHERE (MONTH(DATE_OF_BIRTH) = '03') AND (GENDER = 'W') AND TLNO IS NOT NULL
;
- IS NOT NULL
- Month(date)
- Year(date), Day(date)도 또한 가능하다.