Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 458 Bytes

3012.md

File metadata and controls

17 lines (14 loc) · 458 Bytes

HAVING Clause Usage

Consider removing the HAVING clause:

Rewriting the query's HAVING clause into a predicate will enable the use of indexes during query processing.

Example

SELECT s.cust_id,count(s.cust_id) FROM SH.sales s GROUP BY s.cust_id
HAVING s.cust_id != '1660' AND s.cust_id != '2'

can be rewritten as:

SELECT s.cust_id,count(cust_id) FROM SH.sales s WHERE s.cust_id != '1660'
AND s.cust_id !='2' GROUP BY s.cust_id