查询某天是一年中的第几周-oracel

 select count(t.user_id ),t.week,t.sign_level  from 
  (select  user_id,aac002, aac003, aac067, channel_no,sign_no, sign_seq,  
  sign_level,to_char(TO_DATE(sign_date, 'YYYYMMDD'), 'yyyyiw') week 
  ,sign_date from essc_user where sign_date>='201812') t
  group by t.week,t.sign_level order by t.week

select to_char(TO_DATE('20190308', 'YYYYMMDD'), 'yyyyiw') as week, --oracle求当年的第几周
       to_char(TO_DATE('20190308', 'YYYYMMDD'), 'yyyyww') as week2, --oracle求当年的第几周
       to_char(TO_DATE('20190308', 'YYYYMMDD'), 'yyyy') as year, --oracle求第几年
       to_char(TO_DATE('20190308', 'YYYYMMDD'), 'yyyymm') as month, --oracle求当年的第几月
       to_char(TO_DATE('20190308', 'YYYYMMDD'), 'yyyyddd') as day, --oracle求当年的第几天
       to_char(TO_DATE('20190308', 'YYYYMMDD'), 'yyyyq') as quarter -- oracle求当年的第几季
      度
 from dual

 

你可能感兴趣的:(oracle,查询周次,Oracle)