calculate the total price

Hello Experts,

I have a query which pulls information on the orders sent until today, Please can someone help me in finding the sum ordertotal, sum of ordershipping  and sum of orderlineprice

All I wanted the total amount between 1-sep-2007 to 31-aug-08

your help is greatly appreciated

thanks
kay
SELECT     dbo.[Order].OrderID, dbo.[Order].OrderDate, dbo.[Order].OrderTotal, dbo.[Order].OrderShipping, dbo.OrderDetail.OrderLineProdName, 
                      dbo.OrderDetail.OrderLineQty, dbo.OrderDetail.OrderLineIncVAT, dbo.OrderDetail.RowID, dbo.OrderDetail.OrderLinePrice
FROM         dbo.[Order] INNER JOIN
                      dbo.OrderDetail ON dbo.[Order].OrderID = dbo.OrderDetail.OrderID
WHERE     (dbo.[Order].OrderIncludeInWeeklySummary = 0)

Open in new window

learningnetAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chapmandewCommented:
SELECT
      dbo.[Order].OrderID,
      dbo.[Order].OrderDate,
      dbo.[Order].OrderTotal,
      dbo.[Order].OrderShipping,
      dbo.OrderDetail.OrderLineProdName,
      dbo.OrderDetail.OrderLineQty,
      dbo.OrderDetail.OrderLineIncVAT,
      dbo.OrderDetail.RowID,
      dbo.OrderDetail.OrderLinePrice,
      a.*
FROM
      dbo.[Order]
      INNER JOIN dbo.OrderDetail ON dbo.[Order].OrderID = dbo.OrderDetail.OrderID
      INNER JOIN (
                  select
                        orderid,
                        sum(ordertotal) as ordertotal,
                        sum(ordershipping) as ordershippingtotal,
                        sum(orderlineprice) as orderlinepricetotal
                  from
                        orderdetail
                  group by
                        orderid
                 ) a ON [Order].OrderID = a.[OrderID]
WHERE
      (dbo.[Order].OrderIncludeInWeeklySummary = 0)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kevin CrossChief Technology OfficerCommented:
Or something ike this if you only want the sum through period you specified.
SELECT    SUM(dbo.[Order].OrderTotal) AS SumOrderTotal
, SUM(dbo.[Order].OrderShipping) AS SumOrderShipping
, SUM(dbo.OrderDetail.OrderLinePrice) AS SumOrderLinePrice
FROM         dbo.[Order] INNER JOIN
                      dbo.OrderDetail ON dbo.[Order].OrderID = dbo.OrderDetail.OrderID
WHERE     (dbo.[Order].OrderIncludeInWeeklySummary = 0)
AND dbo.[Order].OrderDate >= '2007-09-01 00:00:00' AND dbo.[Order].OrderDate < '2008-09-01 00:00:00'

Open in new window

0
chapmandewCommented:
Good addition Kevin...wasn't sure if the author wanted to keep the current detail they had or not.  I almost wrote the same thing you just did.  ;)
0
Kevin CrossChief Technology OfficerCommented:
:) Yes, I am not sure either.  Think what you wrote is good too.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.