Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

SQL Script help

Posted on by Microsoft Employee

 Hi, I am trying to get unique records as a result of the following query but it is not working-

SELECT

DISTINCT A.ACTINDX,

A.ACTNUMBR_1,

A.ACTNUMBR_2,

A.ACTNUMBR_3,

A.ACTNUMBR_4,

A.ACCTTYPE,

A.ACTDESCR,

A.PSTNGTYP,

A.ACCATNUM,

A. TPCLBLNC,

B.TRXDATE

FROM GL00100 A

JOIN GL20000 B ON

A.ACTINDX = B.ACTINDX

WHERE

B.TRXDATE BETWEEN '04-01-2014' AND GETDATE()

OR

A.CREATDDT >'04-01-2014'


I would like just one Acccount Index for every row, any help

*This post is locked for comments

  • Suggested answer
    L Vail Profile Picture
    L Vail 65,271 on at
    RE: SQL Script help

    How about this:

    SELECT Max(DISTINCT gl20000.trxdate) AS LatestTrxDate
           , gl00105.actnumst
           , gl00100.creatddt
           , gl00100.actnumbr_1
           , gl00100.actnumbr_2
           , gl00100.actnumbr_3
           , gl00100.actnumbr_4
           , gl00100.accttype
           , gl00100.pstngtyp
           , gl00100.actdescr
           , gl00100.accatnum
           , gl00100.tpclblnc
    FROM   gl00100
           INNER JOIN gl00105
                   ON gl00100.actindx = gl00105.actindx
           LEFT OUTER JOIN gl20000 AS gl20000
                        ON gl00105.actindx = gl20000.actindx
    GROUP  BY gl00105.actnumst
              , gl00100.creatddt
              , gl00100.actnumbr_1
              , gl00100.actnumbr_2
              , gl00100.actnumbr_3
              , gl00100.actnumbr_4
              , gl00100.accttype
              , gl00100.pstngtyp
              , gl00100.actdescr
              , gl00100.accatnum
              , gl00100.tpclblnc
    HAVING ( Max(DISTINCT gl20000.trxdate) BETWEEN
             CONVERT(DATETIME, '2014-04-01 00:00:00',
                    102) AND Getdate() )
            OR ( gl00100.creatddt > CONVERT(DATETIME, '2014-04-01 00:00:00', 102) )
    ORDER  BY gl00105.actnumst   

    I think it will give you every account created after 4-1-2014 or used in a transaction since 4-1-2014 regardless of when it was created.

    Kind regards,

    Leslie

  • L Vail Profile Picture
    L Vail 65,271 on at
    RE: SQL Script help

    Hi,

    This will be an easy one for all of the SQL gurus. Question, what are you trying to find out? Do you want to find out?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans