Error, al usar un CASE
Publicado por Paola Jaimes (2 intervenciones) el 27/05/2008 16:50:29
SELECT
a."doc-num" as doc_num,
a."doc-fec" as doc_fec,
a."vcto-fec" as vcto_fec,
a."vcto-val" as vcto_val,
a."cor-ano" as cor_ano,
a."cta-cod" as cta_cod,
a."est-cod" as est_cod,
a."vcto-ini" as vcto_ini,
a."clc-cod" as clc_cod,
CASE
WHEN (a."vcto-fec"-:FECHA_CORTE)<30 THEN 'VENCE A 30 DIAS'
WHEN (a."vcto-fec"-:FECHA_CORTE)<60 THEN 'VENCE A 60 DIAS'
WHEN (a."vcto-fec"-:FECHA_CORTE)<90 THEN 'VENCE A 90 DIAS'
ELSE 'VENCIMIENTO A + 90 DIAS' END AS VENCE,
FROM
PUB.con_vctos a
WHERE
(a."cor-ano" = 2008 AND
(a."cta-cod" LIKE '11050502' OR
a."cta-cod" LIKE '130505%') AND
(a."clc-cod" = 'NCC' OR
a."clc-cod" = 'NDC' OR
a."clc-cod" = 'CHD' OR
a."clc-cod" = 'SI' OR
a."clc-cod" = 'TRA' OR
a."clc-cod" = 'FV') AND
a."est-cod" = 105 AND
a."doc-fec" <=:FECHA_CORTE
ORDER BY a."doc-num"
Aclaro que FECHA_CORTE es un parámetro, la cual puede coincidir con la fecha actual.
Cuando ejecuto la consulta me genera un error por la segunta condición del CASE.
a."doc-num" as doc_num,
a."doc-fec" as doc_fec,
a."vcto-fec" as vcto_fec,
a."vcto-val" as vcto_val,
a."cor-ano" as cor_ano,
a."cta-cod" as cta_cod,
a."est-cod" as est_cod,
a."vcto-ini" as vcto_ini,
a."clc-cod" as clc_cod,
CASE
WHEN (a."vcto-fec"-:FECHA_CORTE)<30 THEN 'VENCE A 30 DIAS'
WHEN (a."vcto-fec"-:FECHA_CORTE)<60 THEN 'VENCE A 60 DIAS'
WHEN (a."vcto-fec"-:FECHA_CORTE)<90 THEN 'VENCE A 90 DIAS'
ELSE 'VENCIMIENTO A + 90 DIAS' END AS VENCE,
FROM
PUB.con_vctos a
WHERE
(a."cor-ano" = 2008 AND
(a."cta-cod" LIKE '11050502' OR
a."cta-cod" LIKE '130505%') AND
(a."clc-cod" = 'NCC' OR
a."clc-cod" = 'NDC' OR
a."clc-cod" = 'CHD' OR
a."clc-cod" = 'SI' OR
a."clc-cod" = 'TRA' OR
a."clc-cod" = 'FV') AND
a."est-cod" = 105 AND
a."doc-fec" <=:FECHA_CORTE
ORDER BY a."doc-num"
Aclaro que FECHA_CORTE es un parámetro, la cual puede coincidir con la fecha actual.
Cuando ejecuto la consulta me genera un error por la segunta condición del CASE.
Valora esta pregunta


0