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

Re: Query help

$
0
0

THanks for answer.

 

I have used this one:

 

SELECT TOP 1 PO.[no. SO], SUM(PO.[total PO]),

stuff

 

 

(

( select ',' + convert(nvarchar,d.DocNum) from

(

select distinct DocNum, CAST(U_SO_Number AS NVARCHAR(20)) [NO. SO]  from OPOR

) d

where d.[NO. SO] = CAST(ORDR.DocNum AS NVARCHAR(20)) for xml PATH('')),1,1,''

) as [NO. PO],

SUM(RDR1.LineTotal) [SO Total] FROM ORDR INNER JOIN RDR1 ON RDR1.DocEntry=ORDR.DocEntry

LEFT JOIN

 

 

(SELECT DISTINCT OPOR.DocNum [no. PO], opor.U_SO_Number [no. SO], OPOR.DocTotal [total PO]

from por1 inner join OPOR with (nolock) on opor.DocEntry=por1.DocEntry where opor.DocType='i'

  ) PO on

  PO.[NO. SO] = cast(ordr.DocNum as nvarchar(20))

 

  where ordr.docNum =xxxxx0006

 

  GROUP BY PO.[no. PO], PO.[no. SO], ORDR.DocNum

 

here is the result print screen:

 

 

PO.png

 

The NO. PO columns have successful displayed 2 PO Numbers but the Total amount of PO is still from one PO.

 

Pls provide a solution to solve this issue. Thank you

 

Rgds,

Steve


Viewing all articles
Browse latest Browse all 10548

Trending Articles