Question
Download Solution PDFThe _____ clause is an additional filter that is applied to the result set in a SQL statement.
This question was previously asked in
MP Vyapam Group 4 (Assistant Grade-3/Stenographer) Official Paper (Held On: 16 July, 2023 Shift 2)
Answer (Detailed Solution Below)
Option 3 : Having
Free Tests
View all Free tests >
MP व्यापम ग्रुप 4 सामान्य हिंदी सब्जेक्ट टेस्ट 1
6.3 K Users
20 Questions
20 Marks
20 Mins
Detailed Solution
Download Solution PDFThe correct answer is Having.
Key Points
- The HAVING clause is used in SQL to apply an additional filter to the result set after the GROUP BY clause has been executed.
- While the WHERE clause is used to filter rows before any groupings are made, the HAVING clause is used to filter groups after the GROUP BY clause has been applied.
- For example, you can use the HAVING clause to filter groups based on aggregate functions like COUNT, SUM, AVG, etc.
- Consider the following SQL statement:
SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) > 5;
- This query groups the employees by their department and then filters out any departments with 5 or fewer employees.
- Thus, the HAVING clause is particularly useful for conditions that involve aggregate functions, which cannot be used in the WHERE clause.
Additional Information
- The HAVING clause can be used with multiple aggregate functions to perform complex filtering operations.
- For instance, you might want to filter groups based on the average salary in a department and the total number of employees in that department:
-
SELECT department, AVG(salary), COUNT(*) FROM employees GROUP BY department HAVING AVG(salary) > 50000 AND COUNT(*) > 5;
- This query will return only those departments where the average salary is greater than $50,000 and the number of employees is more than 5.
- Unlike the ORDER BY clause which is used to sort the result set, the HAVING clause is used specifically for filtering groups.
Last updated on May 14, 2025
-> The MP Vyapam Group 4 Response Sheet has been released for the exam which was held on 7th May 2025.
-> A total of 966 vacancies have been released.
->Online Applications were invited from 3rd to 17th March 2025.
-> MP ESB Group 4 recruitment is done to select candidates for various posts like Stenographer Grade 3, Steno Typist, Data Entry Operator, Computer Operator, Coding Clerk, etc.
-> The candidates selected under the recruitment process will receive MP Vyapam Group 4 Salary range between Rs. 5200 to Rs. 20,200.