我期待从年初开始的所有星期六,并为他们分配号码。
例如:如果我给出变量80,4那么它应该从年初的所有80个星期六开始并除以4并给出大小数字
SL DATES SIZE
1 02-JAN-16 1
2 09-JAN-16 1
3 16-JAN-16 1
4 23-JAN-16 1
5 30-JAN-16 2
6 06-FEB-16 2
7 13-FEB-16 2
8 20-FEB-16 2
9 27-FEB-16 3
10 05-MAR-16 3
11 12-MAR-16 3
.... …
.... …
.... …
72 20-MAY-17 19
73 27-MAY-17 19
74 03-JUN-17 19
75 10-JUN-17 19
76 17-JUN-17 20
78 24-JUN-17 20
79 01-JUL-17 20
80 08-JUL-17 20
答案 0 :(得分:1)
SELECT LEVEL AS SL,
NEXT_DAY( TRUNC( SYSDATE, 'YEAR' ) + 7 * LEVEL - 8, 'SATURDAY' ) AS DATES,
CEIL( LEVEL / :divisor ) AS "SIZE"
FROM DUAL
CONNECT BY LEVEL <= :limit;