Link to home
Create AccountLog in
Avatar of rp
rpFlag for Portugal

asked on

sql server conditional query in sum

i have a query like this:

select sum(credito)-SUM(Debito) as Saldo from movimentostesouraria where idconta=1 and DataDocumento < '2010-11-20'
group by idconta

If sum(credito)-SUM(Debito) is positive i need put result value in Credito column, otherwise in Debito column (not is saldo)
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account