este...ahi tienes la solucion a tu problema, es solo que cambies la tabla #temp por la tabla de tus datos, que las condiciones las acomodes a tus codigos de condiciones y con eso te sirve tanto para 5 datos como para 500 o para que entiendas:
Código SQL:
Ver originalSELECT
C1.C_CODCLI,
C2.C_NOMPER,
C4.C_CODTIT,
C4.N_SALCAP,
C3.C_CODPRO,
C3.C_DESCRI,
C1.N_SALCAP,
(CASE
WHEN C3.C_CODPRO='165043' OR C3.C_CODPRO='165001' OR C3.C_CODPRO='165052' OR C3.C_CODPRO='165019' THEN c1.Nsalcap END AS 'ORDINARIO',
CASE WHEN C3.C_CODPRO='165045' OR C3.C_CODPRO='165003' THEN c1.Nsalcap END AS 'INSTITUCIONAL',
CASE WHEN C3.C_CODPRO='165031' THEN c1.Nsalcap END AS 'PROG CREDITICIA',
CASE WHEN C3.C_CODPRO='165055' THEN c1.Nsalcap END AS 'APOYO FINANCIERO',
CASE WHEN C3.C_CODPRO='165053' THEN c1.Nsalcap END AS 'SOCIAL',
CASE WHEN C3.C_CODPRO='165052' THEN c1.Nsalcap END AS 'NUEVO',
CASE WHEN c3.c_cpdpro NOT IN (165043,165001,....) THEN c1.Nsalcap END AS 'OTROS'
FROM
CRMCTCR C1, CLMPERS C2, CRTPROD C3, CEMCUEN C4
WHERE
C1.C_CODCLI=C2.C_CODPER AND C2.C_CODPER=C4.C_CODTIT AND C1.C_CODPRO=C3.C_CODPRO AND C1.C_ESTCRE='VG' AND C4.C_CODEST='V'
ORDER BY C2.C_CODPER