Complete the code to group the results by the "department" column.
SELECT department, COUNT(*) FROM employees [1] department;The GROUP BY clause groups rows that have the same values in specified columns. Here, it groups by the department column.
Complete the code to show the average salary for each job title.
SELECT job_title, AVG(salary) FROM employees [1] job_title;The GROUP BY clause groups rows by job_title so the average salary is calculated per job title.
Fix the error in the query to correctly group by "category".
SELECT category, SUM(quantity) FROM sales [1];The correct syntax is GROUP BY category. It groups rows by the category column.
Fill both blanks to group by "region" and filter groups with total sales over 1000.
SELECT region, SUM(sales) FROM sales_data [1] region [2] SUM(sales) > 1000;
Use GROUP BY region to group rows by region. Then use HAVING to filter groups where the sum of sales is greater than 1000.
Fill all three blanks to select the department name, count employees, and filter departments with more than 5 employees.
SELECT [1], COUNT(*) FROM employees [2] [1] [3] COUNT(*) > 5;
Select department, group by it using GROUP BY, and filter groups with more than 5 employees using HAVING.