thegleek wrote:yeah well, i still probably would never use an IF or CASE statement within a sql query... it's just not in my coding ethics to do so...
So you've got something against writing efficient code?
The reason SQL constructs like
case exist in the first place -- and are allowed within a
select -- is to allow you to explicitly tell the DBMS what you are trying to accomplish. This allows the DBMS to optimize the query for efficient execution. Simply pulling all of the data and sorting through it using a procedural language can be horrendously inefficient in comparison.
This kind of optimization becomes even more important in multi-tier applications where the DBMS is running on a machine other than the one issuing the query, since it can reduce the amount of data sent over the network by orders of magnitude.