You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
annetts edited this page Nov 10, 2014
·
5 revisions
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;