最近項目中要出一個按月
某年按月分組
Sql代碼
SELECT A
FROM
(
SELECT ROWNUM AS D FROM SYS_UNUSE WHERE ROWNUM <
) A
LEFT JOIN
(
SELECT TO_CHAR(T
WHERE T
GROUP BY TO_CHAR(T
) B ON A
某月按日分組
Sql代碼
SELECT A
FROM
(
SELECT ROWNUM AS D FROM SYS_UNUSE WHERE ROWNUM <= TO_CHAR(LAST_DAY(:prDate)
) A
LEFT JOIN
(
SELECT TO_CHAR(T
WHERE T
GROUP BY TO_CHAR(T
) B ON A
按周統計
Sql代碼
SELECT A
FROM
(
SELECT TO_CHAR(:prDate+ROWNUM
) A
LEFT JOIN
(
SELECT TO_CHAR(T
WHERE T
GROUP BY TO_CHAR(T
) B ON A
說明
From:http://tw.wingwit.com/Article/program/Oracle/201311/18420.html