web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Open Vendor Invoices - SQL QUERY

(0) ShareShare
ReportReport
Posted on by

Hi All,

I would like to get the same result (SQL QUERY) as in Accounts Payable - Common - Vendor Invoices - Open Vendor Invoices datagrid but my SQL query returns more lines than in the datagrid.

Export to Excel = 1421 lines

SQL Query = 1575 lines

Here is my query :

SELECT 'Open Vendor Invoices' AS INVOICETYPE
     ,VTO.ACCOUNTNUM
     ,VTO.AMOUNTCUR
     ,VTO.AMOUNTMST
     ,VTO.DUEDATE
     ,VTO.TRANSDATE
     ,VTR.INVOICE
FROM VENDTRANSOPEN VTO
JOIN VENDTRANS VTR ON VTO.REFRECID = VTR.RECID AND VTO.ACCOUNTNUM = VTR.ACCOUNTNUM
JOIN VENDTABLE VTA ON VTR.ACCOUNTNUM = VTA.ACCOUNTNUM
WHERE VTR.APPROVED = 1
OR VTR.TRANSTYPE = 36
OR VTR.TRANSTYPE = 3
OR VTR.TRANSTYPE = 14

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,668 Super User 2026 Season 1 on at

    Would you like to read some theory behind all concept? probably that can help you to understand data structure

    community.dynamics.com/.../210639

    go though this and get back with your question, in case you face difficulty to fix this.

  • Suggested answer
    Brandon Wiese Profile Picture
    17,790 on at

    For starters, you should include DATAAREAID in your joins, and PARTITION if you're version of AX includes it.  You could have multiple vendors with the same ACCOUNTNUM but in different companies, and that mis-join could be exploding your data.

    Additionally, rather than use TRANSTYPE as a filter, join to VENDINVOICEJOUR, which are actual invoices.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dserp Profile Picture

dserp 4

#2
dekion Profile Picture

dekion 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans