Link to home
Start Free TrialLog in
Avatar of dkilby
dkilbyFlag for Canada

asked on

ms sql last 8 weeks as columns

I need a query that shows how much each customer has ordered for the last 8 weeks, and the week dates are the columns.

Something Like

Customer ID  11/27/2016   12/4/2016   12/11/2016  12/18/2016..........
124355               $48.50            $156.00    $25.00             $32.00

The total for the week is a sum of all orders for that week.

what is the easiest way to do this ?

Thanks
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Please post the column names
SELECT 
   Val1,
   Val2,
   Val3,
   (Val1 + Val2 + Val3) as 'Total'
FROM Emp

Open in new window

Can you please provide few rows ?
Avatar of dkilby

ASKER

Customer ID
DateOfOrder
AmountOfOrder

are the columns names I am working with.
SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial