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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

SQL query help

(0) ShareShare
ReportReport
Posted on by

I'm looking for a SQL query that will pull sales for a year with GL distribution AND the ship to state.  Does this query look ok - I'm not sure about the joins

select
'xxx' COMPANY,
OPENYEAR Trx_Year,
TRXDATE Trx_Date,
JRNENTRY Journal_Entry,
ORTRXSRC Originating_TRX_Source,
ORMSTRID Originating_Master_ID,
ORMSTRNM Originating_Master_Name,
ORDOCNUM Originating_Doc_Number,
DEBITAMT Debit_Amount,
CRDTAMNT Credit_Amount,
ACTNUMST Account_Number,
ACTDESCR Account_Description,
ACCATDSC Account_Category,
ORPSTDDT originating_post_date,
ORIGNUMB SOPORIGNUMB,
STATE

from
(select ACTINDX, OPENYEAR, TRXDATE, JRNENTRY, ORTRXSRC, ORPSTDDT,
ORDOCNUM, ORMSTRID, ORMSTRNM, DEBITAMT, CRDTAMNT
from GL20000
where (SERIES = '3') and OPENYEAR = '2015') GL

inner join GL00105 GM
on GL.ACTINDX = GM.ACTINDX
inner join GL00100 GA
on GL.ACTINDX = GA.ACTINDX
inner join GL00102 C
on GA.ACCATNUM= C.ACCATNUM
inner join SOP30200  S
on GL.ORDOCNUM= S.ORIGNUMB

go

*This post is locked for comments

I have the same question (0)
  • Verified answer
    L Vail Profile Picture
    65,271 on at

    Hi,

    I think you might want something like this:

    SELECT GL20000.OPENYEAR AS Trx_Year

    ,GL20000.TRXDATE AS Trx_Date

    ,GL20000.JRNENTRY AS Journal_Entry

    ,GL20000.ORTRXSRC AS Originating_TRX_Source

    ,GL20000.ORMSTRID AS Originating_Master_ID

    ,GL20000.ORMSTRNM AS Originating_Master_Name

    ,GL20000.ORDOCNUM AS Originating_Doc_Number

    ,GL20000.DEBITAMT AS Debit_Amount

    ,GL20000.CRDTAMNT AS Credit_Amount

    ,GL00105.ACTNUMST AS Account_Number

    ,GL00100.ACTDESCR AS Account_Description

    ,GL00102.ACCATDSC AS Account_Category

    ,GL20000.ORPSTDDT AS originating_post_date

    ,SOP30200.sopnumbe AS SOP_Number

    ,SOP30200.SOPTYPE AS SOP_Type

    ,SOP30200.STATE

    FROM GL20000

    INNER JOIN SOP30200 ON GL20000.ORDOCNUM = SOP30200.SOPNUMBE

    INNER JOIN GL00100 ON GL20000.ACTINDX = GL00100.ACTINDX

    INNER JOIN GL00105 ON GL20000.ACTINDX = GL00105.ACTINDX

    INNER JOIN GL00102 ON GL00100.ACCATNUM = GL00102.ACCATNUM

    WHERE (GL20000.SERIES = '3')

    AND (GL20000.OPENYEAR = '2015')

    Kind regards,

    Leslie

  • Verified answer
    Community Member Profile Picture
    on at

    OMG - this is awesome!   I know my joins were messing me up.

    Thank you so very much Leslie!  My only other tweak was to add SOPTYPE = '3' because I just needed to get 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans