usar case en sql con sum
Publicado por oqueller (7 intervenciones) el 28/11/2018 18:12:56
Como puedo hacer esto en una sola intruccion ya se apor case o otra alternativa en una solo setencia
Exec SQL
Select IFNULL(SUM(STDAMT), 0) into :CargoS
from SCDTL
where STDACC = :SThacc And STDDCC = '0'
And STDBDY =2018 And STDBDM = 09 And Stdnum=:Sthnum;
* ABONO
Exec SQL
Select IFNULL(SUM(STDAMT), 0) into :ABONOS
from SCDTL
where STDACC = :SThacc And STDDCC = '5'
And STDBDY =2018 And STDBDM = 09 And Stdnum=:Sthnum;
Exec SQL
Select IFNULL(SUM(STDAMT), 0) into :CargoS
from SCDTL
where STDACC = :SThacc And STDDCC = '0'
And STDBDY =2018 And STDBDM = 09 And Stdnum=:Sthnum;
* ABONO
Exec SQL
Select IFNULL(SUM(STDAMT), 0) into :ABONOS
from SCDTL
where STDACC = :SThacc And STDDCC = '5'
And STDBDY =2018 And STDBDM = 09 And Stdnum=:Sthnum;
Valora esta pregunta


0