Complete the code to calculate the total salary from the employees table.
SELECT SUM([1]) FROM employees;The SUM function adds up all values in the specified column. Here, we want to sum the salary column.
Complete the code to find the total sales from the orders table.
SELECT SUM([1]) FROM orders;The SUM function should be used on the column that holds the sales amount, which is total_amount.
Fix the error in the code to correctly sum the prices in the products table.
SELECT SUM([1]) FROM products;The SUM function must be used on a numeric column like price. Using product_name or category causes errors because they are text.
Fill both blanks to calculate the total quantity sold for product_id 101 in sales table.
SELECT SUM([1]) FROM sales WHERE [2] = 101;
We sum the quantity column to get total units sold. The WHERE clause filters rows where product_id equals 101.
Fill all three blanks to calculate the total revenue for customer 'John' in orders table.
SELECT SUM([1]) FROM orders WHERE [2] = '[3]';
We sum the total_amount column to get revenue. The WHERE clause filters orders where customer_name is 'John'.