Homework5 - Angelaader/l6vi GitHub Wiki
Query that returns the most popular product name, total quantity, unit price and unit price multiplied by the total quantity sold (most popular one is the one that gave highest income - last column max number)
SELECT TOP 1
name AS Name,
SUM(quantity) AS Quantity,
itemprice AS Price,
SUM(quantity*itemprice) AS Income
FROM solditem
GROUP BY name, itemprice
ORDER BY Income DESC;
Query that returns the date with the highest income (should return only one row)
SELECT TOP 1
sum(total) as Total,
cast(date as VARCHAR) AS Date
FROM ACCEPTEDORDER
GROUP BY date
ORDER BY Total DESC;