SQL Query - Grouping by weekly date range

Posted on 2011-10-05
Last Modified: 2012-05-12
I need help with a SQL query to group it by weekly date.  Not sure how to go about doing this so that I can get the date to group from Monday - Sunday and give me the sum.  Below is my query and example:


It's a simple query, but I need to be able to group it.  See the screenshot example. Example raw data and final result.
Question by:holemania
    LVL 142

    Accepted Solution

    you can "GROUP BY" the expressions:

    GROUP BY DATEPART(year, your_date_field) , DATEPART(week, your_date_field)

    hope this helps

    Author Closing Comment

    Thank you.  That worked.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
    Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now