Rising Temperature
문제
코드
Oracle
SELECT TODAY.ID AS id
FROM WEATHER TODAY
INNER JOIN WEATHER YESTERDAY ON YESTERDAY.RECORDDATE + (INTERVAL '1' DAY) = TODAY.RECORDDATE
WHERE TODAY.TEMPERATURE > YESTERDAY.TEMPERATURE
MYSQL
SELECT TODAY.ID AS id
FROM WEATHER AS TODAY
INNER JOIN WEATHER AS YESTERDAY ON DATE_ADD(YESTERDAY.RECORDDATE, INTERVAL 1 DAY) = TODAY.RECORDDATE
WHERE TODAY.TEMPERATURE > YESTERDAY.TEMPERATURE
수행 결과
참고사항
Oracle 시간 더하기, 빼기
- INTERVAL
- SYSDATE + (INTERVAL ‘1’ YEAR) –1년 더하기
- SYSDATE + (INTERVAL ‘1’ MONTH) –1개월 더하기
- SYSDATE + (INTERVAL ‘1’ DAY) –1일 더하기
- SYSDATE + (INTERVAL ‘1’ HOUR) –1시간 더하기
- SYSDATE + (INTERVAL ‘1’ MINUTE) –1분 더하기
- SYSDATE + (INTERVAL ‘1’ SECOND) –1초 더하기
- SYSDATE + (INTERVAL ‘02:10’ HOUR TO MINUTE) –2시간10분 더하기
- SYSDATE + (INTERVAL ‘01:30’ MINUTE TO SECOND) –1분30초 더하기
MYSQL 시간 더하기, 빼기
- DATE_ADD(기준날짜, INTERVAL)
- SELECT DATE_ADD(NOW(), INTERVAL 1 SECOND)
- SELECT DATE_ADD(NOW(), INTERVAL 1 MINUTE)
- SELECT DATE_ADD(NOW(), INTERVAL 1 HOUR)
- SELECT DATE_ADD(NOW(), INTERVAL 1 DAY)
- SELECT DATE_ADD(NOW(), INTERVAL 1 MONTH)
- SELECT DATE_ADD(NOW(), INTERVAL 1 YEAR)
- SELECT DATE_ADD(NOW(), INTERVAL -1 YEAR)
- DATE_SUB(기준날짜, INTERVAL)
- SELECT DATE_SUB(NOW(), INTERVAL 1 SECOND)