Skip to content
Advertisement

Prioritize one column over another

DB-Fiddle

In the table above I have different campaigns with their corresponding quantities.
The quantities are filled in different columns.


Now, I want to get the latest available quantity for each campaign based on the following hierarchy:

The result should look like this:

What query do I need to achieve this?

Advertisement

Answer

Use coalesce():

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