Just got a small question. When trying to get a single max-Value of a table. Which one is better?
SELECT MAX(id) FROM myTable WHERE (whatever)
The first one is certainly clearer in the intention.
There shouldn't be a significant performance difference thought for this specific query (they should actually be pretty much identical, even though the result is different if there are no rows in myTable
). Unless you have a valid reason to tune the query (e.g. a proven performance issue), always pick the one which shows the intent of the code.