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

Re: Query, joining tables and pulling OPCH NumAtCard/ORPC NumAtCard at the same time

$
0
0

Hi,

 

Please try this query,

 

SELECT T0.[Canceled],T0.[TrsfrAcct],T0.[DocNum] 'Outgoing Payment No.',T0.[DocDate] As 'Outgoing Payment Date', T0.[CardCode] As 'Customer No.', T0.[CardName] As 'Customer Name',T2.[NumAtCard] As 'Invoice No.', T2.[DocTotal] As 'Invoice Total',

T3.[NumAtCard] As 'Credit Memo No.',T3.[DocTotal] As 'Credit Memo Total', T1.[SumApplied] As 'Invoice Amt. Paid', T0.[TrsfrSum] As 'Outgoing Pmt. Total', T0.[TrsfrRef] As 'Amex Ref. No.',

 

CASE

T0.[TrsfrAcct] WHEN '_SYS00000000283' THEN 'American Express 2836'

END[Credit Card] , (T2.[NumAtCard] + ' \ ' + T3.[NumAtCard])  as CustRef,(T2.[DocTotal]  +    + T3.[DocTotal])  as Custtotal

 

FROM [dbo].[OVPM]  T0

INNER JOIN [dbo].[VPM2]  T1 ON T0.DocNum = T1.DocNum

INNER JOIN OPCH T2 ON T1.DocEntry = T2.DocEntry

INNER JOIN ORPC T3 ON T1.DocEntry = T3.DocEntry

 

WHERE T0.[DocDate] >=[%0] and T0.[DocDate] <=[%1] AND T0.[TrsfrAcct]='_SYS00000000283' AND T0.[Canceled]='N'

ORDER BY T0.[DocDate],T0.[CardName], T0.[TrsfrSum]

 

Thanks


Viewing all articles
Browse latest Browse all 2801

Trending Articles



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