This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Yes, the case expression ends with the end keyword. The alias must go after it.
Databases usually have a function that allows to convert nulls to some value. In Oracle, for example, that would be NVL, and you could write:
Or, if you want to stick to ANSI syntax, you could convert nulls to zero before putting it to the aggregation function:
I don't expect any performance differences here. These alternatives might just make the expression more readable.
Joined: Oct 05, 2010
Wonderful, thanks! Helpful to know that it is the ANSI syntax that keeps the SQL portable across the DBMSes. I tend to be very shortsighted in that regard.