I have the following script -
select sum(duration) as duration from opr
where op in ('GRC','GCQ')
and timestamp between '20130101000000' and '20130930235959'
I receive the value - 34459298 seconds. I would like to include these restrictions - The duration which is
<= '18000000' (seconds) should be multiplied to 0.14
The duration between > '18000000' and <= '27000000' should be multiplied to 0.11
and the duration > '27000000' should be multiplied to 0.09
I have tried with this case statement -
case when duration <= '18000000'
then (duration)*0.14
when duration > '18000000' and duration <= '27000000'
then (duration)*0.11
when duration > '27000000'
then (duration)*0.09
else 0 end as bal
However, I receive this value 34459298 multiplied to 0.09, because it is bigger then '27000000', which is not the idea. The idea is all the seconds which these two op ('GRC','GCQ') had made to be multiplied with the above values.
Could you please help me to do this?