Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Need help on SQL view for SmartList Builder

Posted on by 130

dear Victoria,

I have a problem with a view that I have written, could you please help me with it?

I have TABLE1 that contains the following data (SP means SALESPERSON):

SP     Qty  

------------

A.T     10  

C.C    20  

E.A     40  

C.G    3

And TABLE2 that contains the following:

SP     Qty  

---

A.T     1  

C.C    50  

C.G   80

I believe that if I perform a full outer join E.A will appear in my query's result.

but, in fact, I am trying to execute the following query:

   select A.SP, (A.QTY - B.QTY) as 'QTY'

   FROM TABLE1 A FULL OUTER JOIN TABLE2 B

   ON A.SP = B.SP

and the problem is that I am not getting in my result any row for the salesperson E.A.

how can I force it to show me E.A with 40 as a QTY (as if I was making 40 - 0 = 40)?

any help would be more than appreciated

thank you in advance

*This post is locked for comments

  • Victoria Yudin Profile Picture
    Victoria Yudin 22,766 on at
    Re: Need help on SQL view for SmartList Builder

    Mona,

    I would typically use a UNION in this kind of situation.  Try the following code:

    select a.SP, a.sum(Qty)

    from

    (select SP, Qty from TABLE1

    union all

    select SP, Qty*-1 from TABLE2) a

    group by a.SP

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans