Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10548

Re: Eliminating duplicate entry

$
0
0

Dear All,

 

Thx for your answer.

 

Here is another my query:

 

WITH receipt AS (

        SELECT distinct owor.ItemCode, oign.DocNum, ign1.BaseRef, SUM(ign1.LineTotal) AS total_receipt,

        ROW_NUMBER() OVER (partition by oign.docnum, ign1.baseref

ORDER BY oign.docnum, ign1.baseref) as row

        FROM ign1 inner join OWOR on owor.DocNum=ign1.BaseRef and ign1.ItemCode=owor.ItemCode

        inner join OIGN on oign.DocEntry=ign1.DocEntry

        GROUP BY owor.ItemCode, ign1.baseref, oign.DocNum

     ),

    

    

     issued AS (

        SELECT ige1.ItemCode,  OIGe.DocNum, ige1.BaseRef, sum(ige1.linetotal) as total_issue

        FROM ige1 inner join OWOR on owor.DocNum= ige1.BaseRef

        inner join WOR1 on wor1.DocEntry = owor.DocEntry inner join OIGE on oige.DocEntry= ige1.DocEntry

                group by ige1.ItemCode, ige1.BaseRef, oige.DocNum

     )

SELECT owor.ItemCode,

       owor.DocNum, issued.DocNum as Issued_No,

       SUM(issued.total_issue) AS issuedamount,

       receipt.DocNum as Receipt_No,

       SUM(receipt.total_receipt) AS receiptamount

FROM wor1 inner join owor on owor.DocEntry = wor1.docentry

left outer join issued

on issued.BaseRef = owor.DocNum

left outer join receipt

on receipt.BaseRef = owor.DocNum

where owor.DocNum=154

GROUP BY owor.ItemCode, owor.DocNum, issued.DocNum, receipt.DocNum

 

 

 

 

 

The result using the above query is in the screen capture:

 

Untitled.png

 

The query can't give the expected result. Please help to improve the query so that it can give the expected result as same as in the print screen. Thank you

 

 

Rgds,

Steve


Viewing all articles
Browse latest Browse all 10548

Trending Articles



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