I would like to create a view that presents name and number of a "department" with the max value.
drop view highestvalue;
CREATE VIEW HighestValue AS SELECT s.dept, d.name, SUM(s.quantity) TotalQuantity
FROM sale AS s
INNER JOIN dept AS d ON d.number = s.dept
GROUP BY s.dept, d.name
ORDER BY TotalQuantity;
select * from HighestValue;
Expected result:
Defined view with name and number of the department with most sold items