Oracle date function for the previous month

后端 未结 6 2111
醉梦人生
醉梦人生 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 17:46

    Data for last month-

    select count(distinct switch_id)
      from xx_new.xx_cti_call_details@appsread.prd.com
     where dealer_name =  'XXXX'
       and to_char(CREATION_DATE,'MMYYYY') = to_char(add_months(trunc(sysdate),-1),'MMYYYY');
    

提交回复
热议问题