select from(
SELECT fsi., t1.image_like_count FROM (
select fs_image_no,count() image_like_count from fs_image_like
where TO_CHAR(fs_image_like_date,'iw') = TO_CHAR(SYSDATE,'iw')
GROUP BY fs_image_no
ORDER BY COUNT() DESC
) t1 , fs_board_image fsi
WHERE t1.fs_image_no = fsi.fs_image_no
order by image_like_count desc
)where
where TO_CHAR(fs_image_like_date,'iw') = TO_CHAR(SYSDATE,'iw')
이부분은 현재날짜가 몇째 주 인지 대상 데이터의 날짜의 주와 비교하는 것이다.
select * from (
select bi.fs_board_no ,count(*) image_like_count from fs_image_like il,fs_board_image bi
where TO_CHAR(il.fs_image_like_date,'MM') = TO_CHAR(SYSDATE,'MM')
and il.fs_image_no = bi.fs_image_no
group by bi.fs_board_no
order by image_like_count desc
)where <![CDATA[ROWNUM <= 5]]>
where TO_CHAR(il.fs_image_like_date,'MM') = TO_CHAR(SYSDATE,'MM')
위에서 주와 비교했다면 이것 월을 비교한것