jeudi 13 août 2015

SQL Query for results from 7 days ago

I have a SQL query that I need to update to pull results from exactly 7 days ago. At the moment the query is looking at result 7 days and before. I can't seem to find a character that changes the > to an equals.

SELECT
   distinct(cl.RIID_),
   cl.EMAIL_ADDRESS_  
FROM
   $A$ cl  
JOIN
   $C$ bro 
      ON cl.EMAIL_ADDRESS_ = bro.EMAIL_ADDRESS_   
JOIN
   $D$ cms 
      ON cms.SKU = bro.ITEM  
WHERE
   cl.EMAIL_DELIVERABILITY_STATUS_ = 'D'   
   AND cl.EMAIL_PERMISSION_STATUS_ = 'I'   
   AND (
      cms.CATEGORYNAME = 'Desktop Systems' 
      OR cms.CATEGORYNAME = 'Refurbished Laptops & Tablets' 
      or cms.CATEGORYNAME = 'Laptops & Notebooks' 
   ) 
   AND (
      trunc(bro.ACTIVITY_DATE)
   ) >= (
      Trunc(Cast(From_Tz(Cast(Sysdate As Timestamp ), 'US/Pacific') At Time Zone 'Australia/Sydney' As Date)) - 7
   )

Thanks for your help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire