有時需要使用當年的日歷表,可用下列sql語句實現:
select to_date ((select to_char(sysdate, 'yyyy') from dual) || '0101', 'yyyymmdd') + level - 1 as dayofyear from dual connect by level <= to_char(to_date ((select to_char(sysdate, 'yyyy') from dual) || '1231', 'yyyymmdd'), 'ddd')