question

satyalol avatar image
satyalol asked

Hi, Can anyone please tell me how to get the Number of Orders per territory from the Northwind database?? Regards, Sathya

Northwind Database question on Orders Table

databasetableordernorthwindquestions
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·

What have you tried so far?

0 Likes 0 ·

1 Answer

·
lomas avatar image
lomas answered

You can modify below query:

select b.[TerritoryID],sum(a.[OrderQty]) as 'Total Qty' from [Sales].[SalesOrderHeader] B left join [Sales].[SalesOrderDetail] A

on a. [SalesOrderID]=b.[SalesOrderID]

group by B.[TerritoryID] order by b.[TerritoryID]

--------------------------------------------------------------------------------------------------------------------------

SalesOrderHeader-Contains Territory Information and SalesOrderDetail- Contains order qty.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.