| SELECT | JOB |
| FROM | EMP |
| GROUP BY | JOB |
| HAVING | AVG(SAL) >= 2500 |
HAVING allows the user to set an extraction condition for a GROUP BY clause, whereas a WHERE condition is a condition at the record extraction stage before the records are grouped by GROUP BY.
After the GROUP BY clause, [ HAVING Conditional Expression ], the condition used in the HAVING clause must have a value for each group, so it can be a comparison condition for a grouped key or set function.
Now for the Practice, I will give you two questions.
| EmployeeNo | Name | Date of birth | Department |
| 0001 | Arai Kenji | 1950-02-04 | sales |
| 0002 | Suzuki Taro | 1955-03-13 | general affairs |
| 0003 | Sato Hiroshi | 1961-07-11 | Engineering |
| 0004 | Tanaka Hiroshi | 1958-01-24 | planning |
| 0005 | Suzuki Taro | 1948-11-09 | sales |
| ・・・ | |||
| A | SELECT DISTINCT Name FROM Employees ORDER BY Name |
| B | SELECT Name FROM Employees GROUP BY Name HAVING COUNT(*) > 1 |
| C | SELECT Name FROM Employees WHERE Name > 1 |
| D | SELECT Name FROM Employees WHERE Name = Name |
This completes [ Selection criteria for grouped tables (HAVING)].