전체 글 (102) 썸네일형 리스트형 10_05. Difference between timestamp (날짜,시간 차이 구하기) select * from MyTab T where TIMESTAMPDIFF(MINUTE,T.runTime,NOW()) > 20 TIMESTAMPDIFF(단위, 날짜1, 날짜2); SECOND : 초 MINUTE : 분 HOUR : 시 DAY : 일 WEEK : 주 MONTH : 월 QUARTER : 분기 YEAR : 연 출처: https://extbrain.tistory.com/78 [확장형 뇌 저장소] 10_04. 연속적인 log_id에 대한 시작, 끝 log_id 구해라 (Find the Start and End Number of Continuous Ranges) Since some IDs have been removed from Logs. Write an SQL query to find the start and end number of continuous ranges in table Logs. Order the result table by start_id. The query result format is in the following example: select min(log_id) as start_id ,max(log_id) as end_id from ( select log_id ,row_number()over(order by log_id) as log_no from logs ) a1 group by log_id-log_no ; 10_03. 연속적인 숫자 생성 Recursive CTE 사용 Recursive CTE 개념 Recursive CTE (Common Table Expression)는 CTE 중 자기 자신을 반복적으로 호출하는 CTE이다. with recursive temp as ( select 0 as trans_cnt from transactions union select trans_cnt+1 from temp where trans_cnt < ( select count(*) from transactions group by user_id, transaction_date order by 1 desc limit 1) ) 이전 1 ··· 4 5 6 7 8 9 10 ··· 34 다음