BUEN DIA
estimados agradezco si me pueden ayudar es que hace poco migramos de SQL a HANNA y esto pasando los CR al nuevo lenguaje pero este no me queda bien me sale el siguiente error y envió comando SQL y comando HANNA
AGRADEZCO SU AYUDA
saludos
SQL
SELECT
OINV.DocNum, OINV.DocDate, OINV.CardName, OCRD.AddID, OINV.U_CompRet AS CompRet,
SUM(CASE WHEN VatPrcnt = 0 THEN LineTotal ELSE 0 END) AS Exento,
SUM(CASE WHEN VatPrcnt = 0 THEN 0 ELSE LineTotal END) AS Gravado,
SUM(INV1.VatSum) AS Impuesto,
OINV.WTSum AS IVARetenido, 0 AS Orden,
OINV.CANCELED as Cancelado
FROM
OINV INNER JOIN INV1 ON OINV.DocEntry = INV1.DocEntry
INNER JOIN OCRD ON OINV.CardCode = OCRD.CardCode
WHERE
OINV.U_TipoFactura = 'Contribuyente'
AND DATEPART(YEAR, OINV.DocDate) = {?Anio} AND DATEPART(MONTH, OINV.DocDate) = {?Mes} AND OINV.CANCELED !='C'
GROUP BY
OINV.DocNum, OINV.DocDate, OINV.CardName, OCRD.AddID, OINV.WTSum, OINV.U_CompRet,OINV.CANCELED
UNION
SELECT
ORIN.DocNum, ORIN.DocDate, ORIN.CardName, OCRD.AddID, ORIN.U_CompRet AS CompRet,
-SUM(CASE WHEN VatPrcnt = 0 THEN LineTotal ELSE 0 END) AS Exento,
-SUM(CASE WHEN VatPrcnt = 0 THEN 0 ELSE LineTotal END) AS Gravado,
-SUM(RIN1.VatSum) AS Impuesto,
-ORIN.WTSum AS IVARetenido, 1 AS Orden,
ORIN.CANCELED as Cancelado
FROM
ORIN INNER JOIN RIN1 ON ORIN.DocEntry = RIN1.DocEntry
INNER JOIN OCRD ON ORIN.CardCode = OCRD.CardCode
WHERE
ORIN.U_TipoFactura = 'Contribuyente'
AND DATEPART(YEAR, ORIN.DocDate) = {?Anio} AND DATEPART(MONTH, ORIN.DocDate) = {?Mes} AND ORIN.CANCELED !='C'
GROUP BY
ORIN.DocNum, ORIN.DocDate, ORIN.CardName, OCRD.AddID, ORIN.WTSum, ORIN.U_CompRet,ORIN.CANCELED
ORDER BY Orden, DocNum, DocDate
HANNA
SELECT
T0."DocNum", T0."DocDate", T0."CardName", OCRD."AddID", T0."U_CompRet" AS CompRet,
SUM(CASE WHEN "VatPrcnt" = 0 THEN "LineTotal" ELSE 0 END) AS Exento,
SUM(CASE WHEN "VatPrcnt" = 0 THEN 0 ELSE "LineTotal" END) AS Gravado,
SUM(T1."VatSum") AS Impuesto,
T0."WTSum" AS IVARetenido, 0 AS Orden,
T0."CANCELED" as Cancelado
FROM
"{?Schema@}".OINV T0
INNER JOIN "{?Schema@}".INV1 T1 ON T0."DocEntry" = T1."DocEntry"
INNER JOIN "{?Schema@}".OCRD T2 ON T0."CardCode" = T2."CardCode"
WHERE
T0."U_TipoFactura" = 'Contribuyente'
AND DATEPART(YEAR, T0."DocDate") = {?Anio} AND DATEPART(MONTH, T0."DocDate") = {?Mes} AND T0."CANCELED" !='C'
GROUP BY
T0."DocNum", T0."DocDate", T0."CardName", T2."AddID", T0."WTSum", T0."U_CompRet", T0."CANCELED"
UNION ALL
SELECT
T0."DocNum", T0."DocDate", T0."CardName", OCRD."AddID", T0."U_CompRet" AS CompRet,
SUM(CASE WHEN "VatPrcnt" = 0 THEN "LineTotal" ELSE 0 END) AS Exento,
SUM(CASE WHEN "VatPrcnt" = 0 THEN 0 ELSE "LineTotal" END) AS Gravado,
SUM(T1."VatSum") AS Impuesto,
T0."WTSum" AS IVARetenido, 0 AS Orden,
T0."CANCELED" as Cancelado
FROM
"{?Schema@}".ORIN T0
INNER JOIN "{?Schema@}".RIN1 T1 ON T0."DocEntry" = T1."DocEntry"
INNER JOIN "{?Schema@}".OCRD T2 ON T0."CardCode" = T2."CardCode"
WHERE
T0."U_TipoFactura" = 'Contribuyente'
AND DATEPART(YEAR, T0."DocDate") = {?Anio} AND DATEPART(MONTH, T0."DocDate") = {?Mes} AND T0."CANCELED" !='C'
GROUP BY
T0."DocNum", T0."DocDate", T0."CardName", T2."AddID", T0."WTSum", T0."U_CompRet", T0."CANCELED"
ORDER BY Orden, "DocNum", "DocDate"