- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we apply filtering criteria at group levels of the result set returned by MySQL?
As we know that GROUP BY clause in a SELECT statement can divide the result set, returned by MySQL, in groups. Now if we want to return only some specific groups then need to apply filtering criteria at the group level. It can be done by using HAVING clause inside the GROUP BY clause. The example below will demonstrate it −
Suppose we want to return only the group which is having an average salary of 55000 then we need to use filtering criteria as follows in HAVING clause −
mysql> Select count(*),AVG(salary),Designation from employees GROUP BY designation having AVG(salary) = 55000; +----------+-------------+-------------+ | count(*) | AVG(salary) | Designation | +----------+-------------+-------------+ | 2 | 55000.0000 | Asst.Prof | +----------+-------------+-------------+ 1 row in set (0.00 sec)
- How can we divide the result set returned by MySQL into groups?
- GROUP BY the number of rows returned by GROUP BY in MySQL?
- In MySQL, how can we randomize set of rows or values in the result set?
- How can we get all the unique rows in MySQL result set?
- How can we handle a result set inside MySQL stored procedure?
- How can we get the summary output of a column in MySQL result set itself?
- How can we create a MySQL view with GROUP BY clause?
- How can we get only unique values of a column in MySQL result set?
- How can we specify the number of records to be returned in MySQL output?
- What is the importance of the order of Columns in the SET clause of UPDATE statement? Will it make big difference in result set returned by MySQL?
- How Can MySQL operator precedence affect result set?
- How can we establish MySQL database by using MySQL binary at command prompt?
- How can we apply BIT_LENGTH() function on the column/s of MySQL table?
- MySQL filtering by multiple columns?
- How can we change MySQL user password by using the SET PASSWORD statement?