안녕하세요
초보개발자 치비 입니다.
과목,시간을 그룹으로 묶어서 나타내는 쿼리문인데
select to_char(reg_date,'MM-DD') 오늘날짜, 과목, to_char(sum(decode(to_char(reg_date,'hh24'),'09',1,0))) 시간1, to_char(sum(decode(to_char(reg_date,'hh24'),'10',1,0))) 시간2, to_char(sum(decode(to_char(reg_date,'hh24'),'11',1,0))) 시간3, to_char(sum(decode(to_char(reg_date,'hh24'),'12',1,0))) 시간4, to_char(sum(decode(to_char(reg_date,'hh24'),'13',1,0))) 시간5, to_char(sum(decode(to_char(reg_date,'hh24'),'14',1,0))) 시간6, to_char(sum(decode(to_char(reg_date,'hh24'),'15',1,0))) 시간7, to_char(sum(decode(to_char(reg_date,'hh24'),'16',1,0))) 시간8, to_char(sum(decode(to_char(reg_date,'hh24'),'17',1,0))) 시간9, to_char(sum(decode(to_char(reg_date,'hh24'),'18',1,0))) 시간10, count(*) total from 테이블 group by to_char(reg_date,'MM-DD'),과목 order by 1;
여기서의 문제가 만약에 9시에서 10시 30분까지의 데이터를 구하기 위해서는 어떡해 해야할지 감이 안잡힙니다...
단순히 (reg_date,'hh24:mm'),'09:00',1,0) 이렇게 하면 (reg_date,'hh24:mm'),'10:30',1,0) 이러면 단순히 9시인 데이터와
10시 30분인 데이터만 가져오는 거라서 저가 원하는 데이터를 추줄할 수 가 없었습니다.
어떡해 하면 추출 할 수 있는지 조언을 부탁드립니다. 감사합니다^^