Skip to Content
0

Draft Invoice SQL query

Sep 13, 2017 at 05:58 AM

120

avatar image
Former Member

Hi Everyone,

I am having one query issue with respect to one draft A/P invoice how to fetch the respect posted A/P Invoice in the below query.

SELECT distinct T1.[SeriesName] as 'Location',T0.[CardCode] as 'Supplier-Code', lower(t0.CardName) as 'Vendor Name',t0.docentry as 'Draft No',T0.[DocDate] as 'Draft-Date', t0.NumAtCard as 'Supplier-Invoice No',T0.[U_PWN] as 'Way-Bill No',t0.U_ID as 'Way-Bill Date',t0.U_MD as 'Dispatch Mode', T0.[U_LRDN] ,t0.U_LRDATE,t0.U_DispatchCases, ' ' as 'GRN-Date',t0.U_DOP as 'Freight Payment-Date',t0.U_CNN as 'Cheque Number',t0.U_Bank as 'Bank', t0.U_Amount as 'Freight Payment-Amount',' ' as 'Status', tp.DocEntry as 'AP Invoice Link',tp.DocNum as 'A/P Invoice No',tp.DocDate as 'Date', tp.DocTotal as 'Amount',ty.DocEntry AS 'Outgoing Payment No', ty.DocDate as 'Outgoing Payment Date', ty.DocTotal AS 'Outgoing Payment Total' FROM ODRF T0 INNER JOIN NNM1 T1 ON T0.[Series] = T1.[Series] left join OPCH tp on tp.DocEntry = t0.draftKey left JOIN [dbo].[VPM2] Tw ON Tw.Docentry = Tp.DocEntry left join [dbo].[OVPM] Ty on ty.DocNum = tw.DocNum where t0.ObjType=18

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Danilo Kasparian Sep 13, 2017 at 03:15 PM
0

You just mistyped the alias. It is t0.DocEntry = tp.draftKey instead of tp.DocEntry = T0.draftKey

SELECT distinct T1.[SeriesName] as 'Location',T0.[CardCode] as 'Supplier-Code', lower(t0.CardName) as 'Vendor Name',t0.docentry as 'Draft No',T0.[DocDate] as 'Draft-Date', t0.NumAtCard as 'Supplier-Invoice No',T0.[U_PWN] as 'Way-Bill No',t0.U_ID as 'Way-Bill Date',t0.U_MD as 'Dispatch Mode', T0.[U_LRDN] ,t0.U_LRDATE,t0.U_DispatchCases, ' ' as 'GRN-Date',t0.U_DOP as 'Freight Payment-Date',t0.U_CNN as 'Cheque Number',t0.U_Bank as 'Bank', t0.U_Amount as 'Freight Payment-Amount',' ' as 'Status', tp.DocEntry as 'AP Invoice Link',tp.DocNum as 'A/P Invoice No',tp.DocDate as 'Date', tp.DocTotal as 'Amount',ty.DocEntry AS 'Outgoing Payment No', ty.DocDate as 'Outgoing Payment Date', ty.DocTotal AS 'Outgoing Payment Total' FROM ODRF T0 INNER JOIN NNM1 T1 ON T0.[Series] = T1.[Series] left join OPCH tp on t0.DocEntry = tp.draftKey left JOIN [dbo].[VPM2] Tw ON Tw.Docentry = Tp.DocEntry left join [dbo].[OVPM] Ty on ty.DocNum = tw.DocNum where t0.ObjType=18

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Sep 14, 2017 at 06:05 AM
0

Thanks You very much ..Danilo Kasparian

Share
10 |10000 characters needed characters left characters exceeded