Constant GROUP BY to avoid empty HAVING clause

Hello Guys,

I’m trying to avoid a HAVING clause error generated by a tool.
Should be there any problem just to add a constant GROUP BY ‘1’ like the query below.

SELECT SUM(1) AS COL FROM [Users] GROUP BY ‘1’ HAVING COUNT(1) > 0

May this affect my response.
Thanks,
Sajli

There should not most cases. Depends on query it may not able to push optimizations indexer due to group by. cc @keshav_m

Also try this

SELECT d.COL FROM 
       (SELECT SUM(1) AS COL, COUNT(1) AS cnt FROM [Users] ...) AS d WHERE d.cnt > 0;