Quantcast
Channel: SCN : Unanswered Discussions - Reporting and Printing
Viewing all articles
Browse latest Browse all 776

Duplicate rows on Query with journal entries and AP documents

$
0
0

Hi Experts,

 

I ahve the below query allowing me to have some information from journal entries and retrieve some other from AP docuements and PO.

The thing is the query duplicates rows because the AP docuements have several rows but i don t know how to do to remove them (i guess this has to do with JOIN function...)

 

SELECT
T2.[GroupMask] as 'Account Family',
T2.[FatherNum] as 'Parent Account',
T2.[AcctCode] AS 'Account Code',
T2.[AcctName] AS 'Account Name',
T0.[TaxDate] AS 'Document Date',
T0.[Number] AS 'Number',
T0.[DocSeries] AS 'Document Series',
T0.[BaseRef] AS 'Base Reference',
T0.[TransId] AS 'Transaction Number',
T0.[Ref2] AS 'Reference 2',
T1.[ContraAct] AS 'Offset Account',
T4.[BaseRef] AS 'PO code',
T1.[Project] AS 'Project Code',
T1.[ProfitCode] AS 'Distribution Rule',
T1.[OcrCode2] AS 'Costing Code 2',
T1.[OcrCode3] AS 'Costing Code 3',
T1.[OcrCode4] AS 'Costing Code 4',
(T1.[SYSdeb]-T1.[SYSCred])  AS 'Total Amount EUR',
(T1.[FCDebit]- T1.[FCCredit]) AS 'Total Amount (FC)',
T5.[DocTotalSy] AS 'PO Amount (EUR)'
FROM  [dbo].[OJDT] T0 
INNER  JOIN [dbo].[JDT1] T1  ON  T1.[TransId] = T0.[TransId]  
INNER  JOIN [dbo].[OACT] T2  ON  T2.[AcctCode] = T1.[Account]  AND T2.[AcctCode] = T1.[Account]  
INNER JOIN [dbo].[OPCH] T3 ON T3.[DocNum] = T0.[BaseRef]
INNER JOIN [dbo].[PCH1] T4 ON T3.[DocEntry] = T4.[DocEntry]
LEFT JOIN [dbo].[OPOR] T5 ON T5.[DocNum] = T4.[BaseRef]
WHERE
(T2.[AcctCode] > (N'599999' ) ) AND  (T2.[AcctCode] < (N'799999' ) )
AND (T0.[TaxDate]>= [%0] ) AND (T0.[TaxDate]<= [%1])

Viewing all articles
Browse latest Browse all 776

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>