Почему не работает? Не выводит максимальное?
select q.contactname, q.categoryid, q.productname, MAX(q.[1]) as [2]
from (select distinct customers.contactname, products.CategoryID, Products.ProductName, SUM([Order Details].Quantity) as [1]
from [Order Details]
join Products
on [Order Details].ProductID=products.ProductID
join Orders
on [Order Details].OrderID=orders.OrderID
join Customers
on orders.CustomerID=customers.CustomerID
group by customers.ContactName, products.CategoryID, products.ProductName) q
group by q.contactname, q.categoryid, q.productname