Start learning 50% faster. Sign in now
The HAVING clause is used in SQL to filter groups created by the GROUP BY clause based on an aggregate function. 1. Aggregate Filtering: Unlike the WHERE clause, which filters rows before grouping, HAVING applies conditions on grouped data. 2. Purpose in Query: In this query, the HAVING clause ensures that only those departments with more than 5 employees (as determined by COUNT(*)) are included in the result set. 3. Execution Process: o The GROUP BY groups the data by department_id. o The COUNT(*) calculates the number of employees in each department. o The HAVING clause filters out groups where COUNT(*) is less than or equal to 5. This differentiation between WHERE and HAVING is crucial for effective data querying. Why Other Options Are Incorrect: • A) To filter rows before grouping them: The WHERE clause performs pre-grouping filtering, not HAVING. • C) To apply a condition to the entire table: HAVING only applies conditions to grouped results. • D) To apply conditions only to the COUNT(*) function: While COUNT(*) is used, the HAVING clause applies to groups as a whole. • E) To sort the rows by department_id: Sorting is achieved using the ORDER BY clause, not HAVING.
National Youth Day is celebrated to commemorate the birth anniversary of Swami Vivekananda on____?
Under which banks and non-banking financial companies provide credit up to Rs 10 lakh for entrepreneurial activities to small business units?
Who inaugurated the 4th LG Horse Polo Cup 2024 at Goshan Drass and also unveiled Ladakh’s first Polo Stadium?
The 'Centre of Jain Manuscriptology' established at which university is funded by the Ministry of Minority Affairs with a budget of ₹40 Crore?
How are the clouded tiger cat's survival threats being addressed?
What growth rate did India's defence production achieve in FY24?
National Skill Development Corporation (NSDC) has partnered with ________ under the Skill India Mission to support self-employment and augment entrepren...
Which of the following company has recently announced that it will be investing Rs 2,000 crore for setting up a large hyperscale data centre in Hyderabad?
Which major infrastructure project in Myanmar did the junta revive with Chinese support in 2024?