Oracle date function for the previous month

后端 未结 6 2124
醉梦人生
醉梦人生 2021-02-18 17:25

I have the query below where the date is hard-coded. My objective is to remove the harcoded date; the query should pull the data for the previous month when it runs.

<         


        
6条回答
  •  南笙
    南笙 (楼主)
    2021-02-18 18:09

    Modifying Ben's query little bit,

     select count(distinct switch_id)   
      from xx_new.xx_cti_call_details@appsread.prd.com  
     where dealer_name =  'XXXX'    
       and creation_date between add_months(trunc(sysdate,'mm'),-1) and last_day(add_months(trunc(sysdate,'mm'),-1))
    

提交回复
热议问题