The code below produce results in Fig. 1.Please produce code that will give the results in Fig. 2.Fig. Therefore Fig.2 shows which shipper shipped the leastnumber of orders per category.
Note: DISTINCT doesn’twork
SQL Code:
SELECT CategoryName, CompanyName, MIN(OrderCount) ASMinOrdersShipped
FROM
(
SELECT
C.CategoryName, S.CompanyName
,O.ShipVia
,COUNT(O.OrderID) AS ‘OrderCount’
FROM Orders O
INNER JOIN Shippers S
ON O.ShipVia = S.ShipperID
INNER JOIN [Order Details] D
ON O.OrderID = D.OrderID
INNER JOIN Products P
ON D.ProductID = P.ProductID
INNER JOIN Categories C
ON P.CategoryID = C.CategoryID
GROUP BY C.CategoryName,S.CompanyName, O.ShipVia
) AS SHIPCATCOUNT
GROUP BY CategoryName, CompanyName
ORDER BY CategoryName
PayPal Gateway not configured
PayPal Gateway not configured