SELECT COUNT(*) FROM table1 WHERE COUNT(*) > 5;
In this query, we have called COUNT(*)
twice, causing two computations behind in the scenes. Is this the optimal way to do the query or is there some better way? Does the query engine just cache COUNT(*)
from table1
?
Another example:
SELECT MAX(col1) FROM table1 WHERE MAX(col1) > 5;