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/20032

    9/1/200319

    9/2/200317

    9/2/200320

    9/3/2003109

    9/3/20031

    9/4/200317

    .....

    ...

    9/30/200399

    9/30/20031004

    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