1、case when語句的使用函數
實例:查詢數據,將地址編碼顯示爲具體地點編碼
select m.*, case m.caddr_code when 1 then '住處' when 2 then '交通地點' when 3 then '工做地點' when 4 then '運動休閒' else '其餘' end as caddr_code from Vav_Radio_Sec_Action_Mem m where 1=1
2、 group by分組函數spa
實例:分組查詢20160901至20161031日的數據總數code
select dw.cdate,count(*) from vav_radio_family_mem_weight dw where dw.cdate>=to_date('20160901','yyyymmdd') and dw.cdate<=to_date('20161031','yyyymmdd') and dw.cnetworkid=4205 group by dw.cdate order by dw.cdate
3、to_date ()blog
實例:查詢2016/11/22 2:00:00 至2016/11/23 2:00:00之間的不重複的樣本編號io
select distinct cfamilyid from vav_radio_sec_action_mem where cstart_time>to_date('2016/11/22','yyyy/mm/dd')+2/24 and cstart_time<to_date('2016/11/22','yyyy/mm/dd')+1+2/24 and cregion_id=4205
to_date('2016/11/22','yyyy/mm/dd')+2/24表示2016/11/22增長兩小時/24小時制class
to_date('2016/11/22','yyyy/mm/dd')+1+2/24 表示2016/11/22增長一天和兩小時/24小時制date