5 Replies Latest reply on Oct 31, 2015 2:07 PM by rp0428

    To get the data for last 3 day trend

    grakes

      Hi,

       

      Could you please help me to find out the data based on the last 3 day trend?

      Based on the below sql I can get the total count for last 3 day trend, but I don't know how to get the total count without using UNION ALL. It's taking too much time to get the result. Please help me to find out simple method.

       

      Select TRUNC(SYSDATE) 3Day_Trend, count(Created_Date) from Order

      Where Created_Date <= TRUNC(SYSDATE)

      UNION ALL

      Select TRUNC(SYSDATE)-1 3Day_Trend, count(Created_Date) from Order

      Where Created_Date <= TRUNC(SYSDATE)-1

      UNION ALL

      Select TRUNC(SYSDATE)-2 3Day_Trend, count(Created_Date) from Order

      Where Created_Date <= TRUNC(SYSDATE)-2

       

       

      For Example,

      Name      Order_Id      Created_Date

      A                1                08/21/2015

      A                2                09/18/2015

      A                3                10/25/2015

      B                1                08/12/2015

      B                2                08/23/2015

      B                3                09/14/2015

      B                4                10/26/2015

      C                1                10/24/2015

      C                2                10/25/2015

      C                3                10/26/2015

       

      Expected output:

       

      3Day_Trend      Total_Count

      10/26/2015           10

      10/25/2015            8

      10/24/2015            6

       

      Thanks,

      Guna