The HAVING clause is used to select data records based on a specified condition. You can also apply ZCQL functions in the query using this clause. The HAVING clause can only be used with SELECT queries.
The syntax for using the HAVING clause is shown below:
SELECT column_name FROM base_table_name GROUP BY column_name HAVING column_name OPERATOR condition
Operators Supported by the HAVING Clause
You can use the following operators in the HAVING conditions in ZCQL SELECT queries:
|TRUE if the operand is the same as the value
|TRUE if the operand is a null value
|IS NOT NULL
|TRUE if the operand is not a null value
|Not equal to
|TRUE if the operand matches a pattern
|TRUE if the operand does not match a pattern
|TRUE if the operand value is between the start and end values
|TRUE if the operand is equal to a list of expressions
|TRUE if the operand is not equal to a list of expressions
|Greater than or equal to
|Lesser than or equal to
ZCQL Functions with HAVING Clause
ZCQL functions like SUM(), COUNT(), AVG(), etc., can be used with the HAVING clause in a SELECT query.
The employee details of Zylker Technologies are being maintained in the Data Store in the Zylker_Employee_DB table. The table contains the following columns and rows:
Lets, use the AVG() ZCQL function, with the HAVING clause in an example SELECT query.
SELECT Name, Department, Salary FROM Zylker_Employee_DB GROUP BY Department HAVING AVG(Salary) > 50000
Last Updated 2023-09-05 20:06:31 +0530 +0530
Send your feedback to us