Perhaps you can help me with the SQL query:
I have a conversion value in the secondary table and the following structure:
ID PRICE_BRL PRICE_USD -- --------- --------- 1 10 5 2 12 NULL 3 NULL 3 4 14 NULL 5 NULL 4 6 NULL NULL
I need a set of results. Like the priority of the first column, in the case of NULL, it gives me the second column value multiplied by the transform value stored in the secondary table. Something like, in the pseudocode:
SELECT id, ( IF (price_brl != null) price_brl ELSE price_usd * tbl_2.value ) as final_price FROM tbl_1
I think it should be just using Joins, but I can't figure it out!
Thanks in advance.
source share