What is the total number of purchases for the invoice with Id number 4?

You write the SQL query below. Add a GROUP BY clause that will group the data by invoice Id number.

SELECT
invoice_id,
SUM(quantity) AS total_purchases
FROM
invoice_item
Correct
You add the clause GROUP BY invoice_id to group the data by customer Id number. The complete query is SELECT invoice_id, SUM(quantity) AS total_purchases FROM invoice_item GROUP BY invoice_id. The GROUP BY command groups rows that have the same values from a table into summary rows. GROUP BY is always placed as the last command in a SELECT-FROM-WHERE query.