Policz wartości zamówień, zrealizowane przez każdego pracownika w 1997 roku.
Baza: Northwind, Tabele: dbo.Employees, dbo.Orders, dbo.Order Details, Kolumny: EmployeeID, LastName, Title, UnitPrice, Quantity, Wynik: 9 rows
[spoiler title=’Rozwiązanie’ collapse_link=’true’]SELECT E.EmployeeID as ID, E.LastName, E.Title, SUM(OD.UnitPrice * OD.Quantity) as Sprzedaz
FROM dbo.Employees as E
JOIN dbo.Orders as O on E.EmployeeID = O.EmployeeID
JOIN dbo.[Order Details] as OD on O.OrderID = OD.OrderID
WHERE O.OrderDate >= '19970101′ AND O.OrderDate < '19980101′
GROUP BY E.EmployeeID, E.LastName, E.Title
ORDER BY Sprzedaz DESC;
[/spoiler]