SQL:Count Distinct to_Date to_Char last_day add_months Sysdae Group by

SQL:Count Distinct to_Date to_Char last_day add_months Sysdae Group by

select     count  (  distinct  (di.docu_id  ||  di.policy_no || to_char(di.scan_date,  '  yyyymmdd  '  ))),di.docu_id 
 
from   docu_index di   where   
di.scan_date 
>  last_day(add_months(sysdate,  -   2  ))  +   1     -- 上月第一天
and   
di.scan_date 
<  LAST_DAY(add_months(sysdate,  -   1  ))   -- 上月最后一天  
group     by   di.docu_id 

你可能感兴趣的:(SQL:Count Distinct to_Date to_Char last_day add_months Sysdae Group by)