'Calculate Amount of Product from Northwind
How can I calculate the total amount for product after discount of each EmployeeId in Northwind database of SQL Server?
The tables used from Northwind database are:
- Employees
- Order details
- Products
Solution 1:[1]
If you are calculating amount for each EmployeeId you have to use one more table for join along with these tables
- Orders
- Products
- Employees
- Order Details
and your query should be
select O.EmployeeID,OD.ProductID,Sum(OD.UnitPrice*Quantity *(1-Discount)) as TotalAmount from Orders as o
inner join [Order Details] as OD on OD.OrderID=o.OrderID
inner join Products as p on p.ProductID=OD.ProductID
group by OD.ProductID,o.EmployeeID
order by OD.ProductID
Solution 2:[2]
Write the code (Country, City, TotalCustomer) to show how many customers there are in each city in the country from the Northwind database
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | V2Solutions - MS Team |
| Solution 2 | user19022003 |
