Skip to content
Advertisement

Oracle SQL select greatest value of the result of two different select statements

I’m running select statements in a loop with a cursor to collect data from different tables; Quick (NOT WORKING) example;

What I could like is just one insert statement which insert just the biggest value of boths select statements. I’ve tried to work with greatest function in my loop but i’m running stuck. Both datatypes are the same for value1 and value2

Is it possible with a select case or other way to return only one value based on conditions? For example the biggest value of value1 or value2?

Advertisement

Answer

You can use the greatest function and provide subqueries to it, but – follow the syntax, i.e. enclose each of them (select statements) into its own parenthesis.

Something like this:


I have no idea what is this:

supposed to do; what is crs? Where’s the from clause?

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement