sql server 2008 - Selecting rows as columns with case on SQL -
what want achieve add names current select , highlighted cells on same row
right getting result with
select case sc.tipo when 1 sc.saldoini else 0 end, case sc.tipo when 2 sc.importes1 else 0 end, case sc.tipo when 3 sc.importes1 else 0 end, case sc.tipo when 1 sc.importes1 else 0 end saldoscuentas sc inner join cuentas c on c.id = sc.idcuenta sc.ejercicio = 13 , sc.idcuenta = 131
how go putting highlighted text on 1 row
you can put case statements inside sum function query return 1 row.
sum(case sc.tipo when 1 sc.saldoini else 0 end) saldoini