minium over 4 numeric columns for each row in oracle

LuckyLucks used Ask the Experts™

I need to get the minimum value across 4 columns for each row in a table. Pseudocode is like:  
minimum (nvl(t.rating_A,0), nvl(t.rating_B,0), nvl(t.rating_C,0), nvl(t.rating_D,0)) as min_rating_over4cols_foreachrow

Is this possible with some sort of arithmetic function or something?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Distinguished Expert 2018
Look at LEAST:

least(nvl(t.rating_A,0), nvl(t.rating_B,0), nvl(t.rating_C,0), nvl(t.rating_D,0))
awking00Information Technology Specialist
I think there could be a problem if the desired result is the minimum where any of the columns is not null. You might counter that with something like -
least(nvl(t.rating_A,9999999),nvl(t.rating_B,9999999), nvl(t.rating_C,9999999), nvl(t.rating_D,9999999)) where 9999999 is a number that will always be greater than any of the numbers in the 4 columns. What would you want to retrieve if all of the columns in a given row are null?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial