I want to use the sum function to get the sum of a * b where a is always the value of the "face" column but b can be the value from one of 2 columns dependent on a certain condition. So simply my SQL would look like this if b was a fixed column:
from tableA, tableB....
What is the best way to add logic to this. Basically, below is what I want to do:
select sum(a * [if tableA.code = 1 then use tableA.rate Else use tableB.rate])
from tableA, tableB