The Question : Carefully observe the following table named ‘stock’:Write SQL queries for the following:
A) To display the records in decreasing order of price.
B) To display category and category wise total quantities of products.
C) To display the category and its average price.
D) To display category and category wise highest price of the products.
Solution for the question :
(a) select * from stock order by price desc;
(b) select category, sum(qty) from stock group by category;
(c) select category,avg(price) from stock group by category;
(d) select category, max(price) from stock group by category;
The correct answer to the question is researched by our moderators and shared with you. You can give feedback by commenting for the answers you think are wrong.