Having clause is used to filter data based on the group functions. This is similar to WHERE condition but can be used only with group functions. Group functions cannot be used in WHERE Clause but can be used in HAVING clause.
Example
import sqlite3
connection= sqlite3.connect(“Academy.db”) cursor = connection. cursor( )
cursor.execute(“SELECT GENDER,COUNT(GENDER) FROM Student GROUP BY GENDER HAVING COUNT(GENDER)>3 “)
result = cursor. fetchall( )
co= [i[0] for i in cursor, description]
print(co)
print( result)
OUTPUT
[‘gender’ , ‘COUNT(GENDER)’]
[(‘M’ , 5)]