Performance
August 28, 2019APX1092 – HAVING with non-aggregate functions Description: This rule evaluates the T-SQL script for using HAVING with non-aggregate functions. HAVING should be used only with aggregate functions. For more information visit https://www.techonthenet.com/sql/having.php Example script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
SELECT DataVal, MAX(price) FROM FirstFailedTable GROUP BY DataVal HAVING DataVal LIKE '%abc%'; SELECT DataVal, MAX(price) FROM SecondFailedTable GROUP BY DataVal HAVING DataVal LIKE '%def%'; SELECT DataVal, MAX(price) FROM ThirdFailedTable GROUP BY DataVal HAVING DataVal LIKE '%111%'; SELECT DataVal, MAX(price) FROM FirstGoodTable GROUP BY DataVal HAVING SUM(ID) < 20; SELECT DataVal, MAX(price) FROM SecondGoodTable GROUP BY DataVal HAVING SUM(ID) < 200; |
Message: HAVING clause is used in a non aggregate function APX1096 – Comparison with NULL Description: This rule evaluates the […]