Correct Sql Script for Formula
- by Madan Madan
Can anyone help me write SQL script for the following formula?
If DEP = 1
If DROP 1
PLV = 334.86 * exp(0.3541 * ACTIVE_DAYS) + 0.25 * DROP + 20 * DEP
Else
If DROP < 0
PLV = DROP + 70 * ACTIVE_DAYS
Else
PLV = 0.25 * DROP + 70 * ACTIVE_DAYS
The SQL script which I have is the following
SELECT IF(dep=1, if(dep=1, (334.86 * exp(0.3541 * act_days)) +
(0.25 * 'drop') + (20 * dep),
if('drop'<0, 'drop' + (70 * act_days), (0.25 * 'drop') + (70 * act_days))),'0')
as PLV
But the above query is not right as something is missing where the formula says
Else
PLV = 0.26 * DROP
Thanks,