sql server 2008 - Selecting rows as columns with case on SQL -


what want achieve add names current select , highlighted cells on same row sql results

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


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -