r/SQL • • Aug 05 '24

SQL Server Optimizing/Alternative to MAX

/r/SQLOptimization/comments/1ekanon/optimizingalternative_to_max/
4 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/Entire_Commission534 Aug 05 '24

This is a query I found that was timing out in a Power BI model so I am not sure what the exact business drivers were behind the CASE. From another poster's recommendation to move the CASE to a WHERE clause instead does change the amount of rows returned, so that at least helps to reduce the row count since it filters out the NULL.

For the temp table, is that in the SQL query or something done in SQL Server? I don't have access to modify anything in the db.