troubleshooting Question

Week Calculation and Grouping

Avatar of rcowen00
rcowen00Flag for United States of America asked on
Microsoft SQL Server
3 Comments1 Solution74 ViewsLast Modified:
I have a stored procedure that returns the following data.  The problem I am having is the business users want the report to group by week and sort in Descending order.  Their company week is Mon-Sun and I was using ISO_Week to calculate the week, but I found that the week was then Sat-Sun.  I have listed the results with Wk and ISO_week and you can see how the week order would give me funky order.  I am sure it is simple, but I am having trouble wrapping my mind around how to do the sort order.  Thanks!

Location       Dt                      Cust Ct      Week
2                    2016-01-01      122             1
2                    2016-01-02      155             1
2                    2016-01-03      157             2
2                    2016-01-04      179             2

Location       Dt                      Cust Ct      Week
2                    2016-01-01      122             53
2                    2016-01-02      155             53
2                    2016-01-03      157             53
2                    2016-01-04      179             1
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros