Excelente amigo Libras!, Eres un Master....
Quedo asi:
Código SQL:
Ver originalIF (SELECT COUNT(*) AS Expr1
FROM [tbl_forecast ]
WHERE (cuenta = 2000) AND (departamento = 65011) AND (anio = 2013)) = 1
BEGIN
SELECT 'Forecast:' AS Expr1, enero, febrero, marzo, abril, mayo, junio, julio, agosto, septiembre, octubre, noviembre, diciembre
FROM [tbl_forecast ]
WHERE (cuenta = 2000) AND (departamento = 65011) AND (anio = 2013)
UNION ALL
SELECT 'PRQs:' AS Expr1, '0' AS Expr2, '0' AS Expr3, '0' AS Expr4, '0' AS Expr5, '0' AS Expr6, '0' AS Expr7, '0' AS Expr8, '0' AS Expr9, '0'
AS Expr10, '0' AS Expr11, '0' AS Expr12, '0' AS Expr13
UNION ALL
SELECT 'Saldo:' AS Expr1, '0' AS Expr2, '0' AS Expr3, '0' AS Expr4, '0' AS Expr5, '0' AS Expr6, '0' AS Expr7, '0' AS Expr8, '0' AS Expr9, '0'
AS Expr10, '0' AS Expr11, '0' AS Expr12, '0' AS Expr13
FROM [tbl_forecast ]
WHERE (cuenta = 2000) AND (departamento = 65013) AND (anio = 2013)
END
ELSE
BEGIN
SELECT
'Forecast:' AS Expr1, '0' AS Expr2, '0' AS Expr3, '0' AS Expr4, '0' AS Expr5, '0' AS Expr6, '0' AS Expr7, '0' AS Expr8, '0' AS Expr9, '0'
AS Expr10, '0' AS Expr11, '0' AS Expr12, '0' AS Expr13
UNION ALL
SELECT 'PRQs:' AS Expr1, '0' AS Expr2, '0' AS Expr3, '0' AS Expr4, '0' AS Expr5, '0' AS Expr6, '0' AS Expr7, '0' AS Expr8, '0' AS Expr9, '0'
AS Expr10, '0' AS Expr11, '0' AS Expr12, '0' AS Expr13
UNION ALL
SELECT 'Saldo:' AS Expr1, '0' AS Expr2, '0' AS Expr3, '0' AS Expr4, '0' AS Expr5, '0' AS Expr6, '0' AS Expr7, '0' AS Expr8, '0' AS Expr9, '0'
AS Expr10, '0' AS Expr11, '0' AS Expr12, '0' AS Expr13
END
Muchas gracias.
PD. aun te debo las frias.... no creas que se me ha olvidado.