Complete the code to select all columns from the denormalized table.
SELECT [1] FROM sales_summary;Using * selects all columns from the table.
Complete the code to add a denormalized column that stores total sales.
ALTER TABLE sales_summary ADD COLUMN total_sales [1];The DECIMAL(10,2) type is used for precise numbers with two decimal places, suitable for money.
Fix the error in the query that tries to join normalized tables but misses the join condition.
SELECT orders.order_id, customers.name FROM orders [1] customers;The INNER JOIN keyword joins tables but requires an ON clause separately. The code is missing the ON clause, but the question asks to fix the join keyword only.
Fill both blanks to create a denormalized table that stores customer name and total orders.
CREATE TABLE customer_orders AS SELECT customers.name AS [1], SUM(orders.amount) AS [2] FROM customers JOIN orders ON customers.id = orders.customer_id GROUP BY customers.name;
The alias customer_name clearly labels the customer's name, and total_amount represents the sum of orders, which fits the denormalized data purpose.
Fill all three blanks to write a query that selects denormalized data with a condition on total sales.
SELECT [1], [2] FROM sales_summary WHERE [3] > 1000;
Select the customer name and total sales columns, and filter where total sales is greater than 1000.