SQLite HAVING CLAUSE

SQLite HAVING Clause is used with the combination of Group by clause. It is used to filter the groups that are formed by the Group by Clause based on the specified condition. It is mandatory to use the Group By Clause whenever the HAVING Clause is used and the HAVING Clause is applied to the result set of the Group by Clause to restrict the repeating rows.

Whenever you want to use the WHERE Clause then you need to use it before the Group By Clause followed by the HAVING Clause.

Syntax:

SELECT expression1, expression2, ... expression_n, aggregate_function (aggregate_expression)
FROM tables
WHERE conditions
GROUP BY expression1, expression2, ... expression_n
HAVING condition;

Explanation: We are using the select statement to fetch the data followed by the column_names and the aggregate function and the table name and where condition if required and if the condition is true, then group by condition is applied and on the result of it HAVING Clause is applied.

SQLite HAVING Clause

SQLite is a server-less database engine and it is written in c programming language. The main moto for developing SQLite is to escape from using complex database engines like MySQL etc. It has become one of the most popular database engines as we use it in Television, Mobile Phones, web browsers, and many more. It is written simply so that it can be embedded into other applications. In this article, we will be learning about SQLite HAVING Clauses, how it works, and its functionality.

Similar Reads

SQLite HAVING CLAUSE

SQLite HAVING Clause is used with the combination of Group by clause. It is used to filter the groups that are formed by the Group by Clause based on the specified condition. It is mandatory to use the Group By Clause whenever the HAVING Clause is used and the HAVING Clause is applied to the result set of the Group by Clause to restrict the repeating rows....

Example of HAVING Clause

For better understanding, we are going to use the COMPANY table and the table consists of five columns and they are ID, NAME, AGE, ADDRESS and SALARY. If you don’t know How to Create a Table in SQLite then refer this....

Conclusion

Having Clause is used to filter the rows that are fetched by the Group by Clause. HAVING Clause is used with the aggregate functions like SUM, COUNT, MIN, MAX. In this article we have seen the HAVING Clause with all the aggregate functions and you can clearly understand by looking at the examples. HAVING Clause can used with the Group By Clause only as it specifies a search condition with the group by Clause....