Hi
I am getting error Incorrect Syntax near Union
INSERT INTO "#Final" select A."CardCode",A."CardName",A."Branch",A."DocNo",A."DocDate", A."Remarks",A."Debit",A."Credit" from( select '' As "CardCode",'' As "CardName",'' As "Branch",'' As "DocNo",'' As "DocDate", 'Opg Balance' As "Remarks",(Case when v_opgDebit > v_opgCredit Then v_opgDebit - v_opgCredit End) As "Debit" ,(Case when v_opgCredit <= v_opgDebit Then v_opgCredit - v_opgDebit End) As "Credit" Union All SELECT T3."ShortName" AS "CardCode",(Select Max("CardName") from OCRD where "CardCode" = T3."ShortName") AS "CardName",T3."BPLName" As "Branch", T2."BaseRef" AS "DocNo", T2."TaxDate" as "DocDate", (CASE WHEN T3."TransType"='204' THEN 'A/P Down Payment Invoice' WHEN T3."TransType"='46' THEN 'Outgoing Payment' WHEN T3."TransType"='18' THEN 'A/P Invoice' ELSE ' 'END) AS "Remarks",T3."Debit" As "Debit", T3."Credit" As "Credit" FROM "OJDT" T2 INNER JOIN JDT1 T3 ON T2."TransId" = T3."TransId" WHERE (T3."ShortName"=:BpCode) )A
Thanks