Hi,
I had try to union all, and replaced the unequal column in query two by T0.[TaxDate] AS "JE CREATE DATE", not T7.[DateID] AS "JV CREATE DATE". Because if I do so, it will generate the same result from query 1.
Below is the query that union between query one and two.
It will result in duplicate records of JE created from JV.
The difference was the date in T0.[TaxDate] AS "JE CREATE DATE".
My requirement is to have a query to generate all JE (auto posting and JV) with the selected field below.
Thanks
SELECT T1.[Account],
T2.[AcctName],
T0.[Number],
T0.[BaseRef],
T1.[LineMemo],
T1.[Debit],
T1.[Credit],
T1.[FCCurrency],
T1.[FCDebit],
T1.[FCCredit],
T0.[TaxDate] AS "JE CREATE DATE",
T7.[DateID] AS "JV CREATE DATE",
T0.[RefDate] ,
T6.[Name],
T3.u_name [User Name],
T0.[Creator],
T0.[Approver]
FROM [OJDT] T0
INNER JOIN [JDT1] T1 ON T0.TransId = T1.TransId
INNER JOIN [OACT] T2 ON T1.Account = T2.AcctCode
INNER JOIN [OUSR] T3 on T0.usersign = T3.userid
INNER JOIN NNM1 T5 on T5.series=T0.series and T5.objectcode='30'
INNER JOIN OFPR T6 ON T0.FinncPriod = T6.AbsEntry
INNER JOIN OBTD T7 ON T0.BatchNum = T7.BatchNum
WHERE T0.[RefDate] >=[%0] AND T0.[RefDate] <=[%1]
Union all
SELECT T1.[Account],
T2.[AcctName],
T0.[Number],
T0.[BaseRef],
T1.[LineMemo],
T1.[Debit],
T1.[Credit],
T1.[FCCurrency],
T1.[FCDebit],
T1.[FCCredit],
T0.[TaxDate] AS "JE CREATE DATE",
T0.[TaxDate] AS "JE CREATE DATE",
T0.[RefDate] ,
T6.[Name],
T3.u_name [User Name],
T0.[Creator],
T0.[Approver]
FROM [OJDT] T0
INNER JOIN [JDT1] T1 ON T0.TransId = T1.TransId
INNER JOIN [OACT] T2 ON T1.Account = T2.AcctCode
INNER JOIN [OUSR] T3 on T0.usersign = T3.userid
INNER JOIN NNM1 T5 on T5.series=T0.series and T5.objectcode='30'
INNER JOIN OFPR T6 ON T0.FinncPriod = T6.AbsEntry
WHERE T0.[RefDate] >=[%0] AND T0.[RefDate] <=[%1]