A coffee shop has a sales table with columns drink_type and…

A coffee shop has a sales table with columns drink_type and quantity. The manager wants to see how many drinks of each type were sold. Which query should they use? SELECT drink_type, SUM(quantity) FROM sales GROUP BY drink_type SELECT SUM(quantity) FROM sales SELECT drink_type, quantity FROM sales ORDER BY drink_type SELECT * FROM sales GROUP BY quantity Answer: SELECT drink_type, SUM(quantity) FROM sales GROUP BY drink_type Explanation: GROUP BY drink_type ensures sales are summarized by each drink type, while SUM(quantity) adds up total sales per type. A plain SUM(quantity) gives one total, not per type. Ordering without aggregation only sorts. Grouping by quantity is incorrect because it groups by values sold, not drink type.

An airline tracks ticket sales in a tickets table. Managemen…

An airline tracks ticket sales in a tickets table. Management wants to see the highest-priced tickets first. Which query should they write? SELECT * FROM tickets ORDER BY price ASC SELECT * FROM tickets ORDER BY price DESC SELECT * FROM tickets GROUP BY price SELECT * FROM tickets WHERE price DESC Answer: SELECT * FROM tickets ORDER BY price DESC Explanation: DESC sorts from largest to smallest, so the most expensive tickets appear first. ASC would do the opposite. GROUP BY and WHERE are not used for sorting.

A retail company’s database has a products table with a colu…

A retail company’s database has a products table with a column called price. The CEO asks: What’s the highest price of any product we sell? Which SQL query answers that? SELECT SUM(price) FROM products SELECT MAX(price) FROM products SELECT AVG(price) FROM products SELECT COUNT(price) FROM products Answer: SELECT MAX(price) FROM products Explanation: MAX retrieves the largest single value from the column. SUM adds all prices together, which doesn’t make sense here. AVG provides an average, and COUNT only tells how many product prices are listed.