The SQLite HAVING clause is used for filtering data. It is an optional clause that is used in combination with the SQLite SELECT statement. It provides an alternative to e.g. filtering data with WHERE clauses.
Usually, the HAVING clause is also used in combination with the GROUP BY clause. The syntax is as follows:
SELECT
columname
FROM
tablename
GROUPBY
othercolumnname
HAVING
searchcondition;
Here is an example:
SELECT
customerid,
COUNT(orderid)
FROM
sales
GROUP BY
region
HAVING
region = ‘USA’;