Skip to content
Advertisement

Oracle SQL – implement logic based on CASE expression result

I have following query which returns me of percentage of rows with at least one NULL in any of columns:

Query works fine to me and I am getting valid result.

But I need to do further action in tablec, based on percentage calculated in my SELECT statement. If percentage of rows with NULL is below 30% I need to insert “YES” string inside table “tablec” column “resultcol”, how can I implement such a logic?

Is it for example possible to store SELECT statement result in some temporary variable which will be used in another SQL query?

Advertisement

Answer

You can use:

db<>fiddle here


Update:

If you want to insert a row if it does not exist or change the row if it does exist then:

Or, to just update it:

db<>fiddle here

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