day wise report

  • I have the data which is for 30days,whcih has got 5 mondays and tuesdays and 4 wednesday,thursday,friday,sat'day and sundays.

    Here is the sample data

    data records

    9/1/2003 1

    9/1/2003 2

    9/1/2003 19

    9/2/2003 17

    9/2/2003 20

    9/3/2003 109

    9/3/2003 1

    9/4/2003 17

    .....

    ...

    9/30/2003 99

    9/30/2003 1004

    I have some records for everyday,but i want to get the data daywise ,i'e total records for monday,tuesday,wednesday,,,,sunday.

    How to do this .

    Please help me in this.

    Thanks in advance

    Thanks,

  • 
    
    SELECT DATEPART(dw,DateCol), SUM(AmtCol)
    FROM TheTable
    GROUP BY DATEPART(dw,DateCol)

    You can use CASE() with DATEPART() in the select clause to show the day of week as its name.

    --Jonathan



    --Jonathan

  • Thank you very much

  • quote:


    
    
    SELECT DATEPART(dw,DateCol), SUM(AmtCol)
    FROM TheTable
    GROUP BY DATEPART(dw,DateCol)

    You can use CASE() with DATEPART() in the select clause to show the day of week as its name.

    --Jonathan


    You don't need to use a case statement. If you're only interested in the day rather Monday 1st being different from Monday 8th then use DateName(dw, DateColumn)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply