Results 1 to 2 of 2

Thread: logic required

  1. #1
    Join Date
    Jul 2014
    Posts
    4

    Unanswered: logic required

    hi ,
    i have query below
    SELECT

    YEAR(TO_DATE(AUC_SALE_DATE,'yyyy-mm-dd')) || '-' || WEEK(TO_DATE(AUC_SALE_DATE,'yyyy-mm-dd')) AS SALE_WEEK

    FROM EDWSTG1DV.LDS_REMARKETER_RESULTS
    WHERE AUC_GROSS_SALE_AMT > 0
    AND TO_CHAR (TO_DATE(AUC_SALE_DATE, 'YYYY-MM-DD'), 'YYYYMM') BETWEEN TO_CHAR (ADD_MONTHS(SYSDATE,-36),'yyyymm') AND TO_CHAR(ADD_MONTHS(SYSDATE,0), 'yyyymm')
    AND BB_AVG != 0;


    i tried to implement that if year is 2011 then it will subtract -1 week.can you please help me how can do this in query itself.

  2. #2
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    Code:
    case
       when year(date_col) = 2011
             then date_col - 7 days 
        else date_col
    end
    Dave

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •