Hello guys, i have this query:
select c8.cerveh, sum(c8.monto1) monto1,
(select prima from arysauto a where a.cerveh=c8.cer veh)
priari,
(sum(c8.monto1)-(select prima from arysauto a
where a.cerveh=c8.cer veh)) dif
from clpf08 c8
where c8.ramo=31 and c8.poliza=61002 65 and
c8.stcdcb=' ' and c8.cerveh in (select cerveh from arysauto)
and
exists (select * from clpf07 where ramo=31 and poliza=6100265
and
cerveh=c8.cerve h and actret<>'R')
group by c8.cerveh
That query prints the sum of a value and compares it with a
standalone
value in another table, and then outputs the difference between those
2 values.
Now i want the same query, but to only show the values that have a
difference in absolute value over 1 units. So i tried putting at the
end of the group by the following:
having (sum(c8.monto1) - (select prima from arysauto a where
a.cerveh = c8.cerveh) ) 0
But the query doesn't run with some error that i have another
function
inside a funtion. If i remove the select inside the having and just
put a number it runs, so i am guessing it is the additional select.
There must be a way to do this, but i am stuck. Can someone help?
select c8.cerveh, sum(c8.monto1) monto1,
(select prima from arysauto a where a.cerveh=c8.cer veh)
priari,
(sum(c8.monto1)-(select prima from arysauto a
where a.cerveh=c8.cer veh)) dif
from clpf08 c8
where c8.ramo=31 and c8.poliza=61002 65 and
c8.stcdcb=' ' and c8.cerveh in (select cerveh from arysauto)
and
exists (select * from clpf07 where ramo=31 and poliza=6100265
and
cerveh=c8.cerve h and actret<>'R')
group by c8.cerveh
That query prints the sum of a value and compares it with a
standalone
value in another table, and then outputs the difference between those
2 values.
Now i want the same query, but to only show the values that have a
difference in absolute value over 1 units. So i tried putting at the
end of the group by the following:
having (sum(c8.monto1) - (select prima from arysauto a where
a.cerveh = c8.cerveh) ) 0
But the query doesn't run with some error that i have another
function
inside a funtion. If i remove the select inside the having and just
put a number it runs, so i am guessing it is the additional select.
There must be a way to do this, but i am stuck. Can someone help?
Comment