AugForums.com

An Acumatica User Group

  • Free
    • Start Here
    • In-Person Gatherings
    • Power BI Workshop
    • Podcast
    • Rolodex
    • Blog
    • Forums
  • Paid
    • AugSQL
    • GI Course
    • GI Library
    • Consulting
  • Register
Acumatica Forums

By using this website, you agree to our Terms of Use (click here)

Forums
AUG Forums
Acumatica Generic I...
Compare 2 account b...
 
Notifications
Clear all

Questions Compare 2 account balances and calculate difference

 
Acumatica Generic Inquiries & Pivot Tables
Last Post by Royce Lithgo 8 years ago
7 Posts
3 Users
1 Reactions
3,059 Views
RSS
Royce Lithgo
Posts: 557
 Royce Lithgo
Topic starter
July 2, 2018 1:32 am
(@roycelithgo)
Honorable Member
Joined: 6 years ago

This is the basis of a bigger solution i am working on, but I need to get this working as its the core of that solution. I'm reasonably new to GI, but have a lot of SQL experience (mostly Oracle). My query works fine where there are rows found for each both accounts, but doesn't work when the right table has no data.

This was cloned to an F200 training database to submit here. 

Now when I run this query, I get the following (correct results).

If I change the account 303000 to 304000 (which doesn't have data), no rows are returned at all. I would expect null values to be returned for fields from the right table as it is related via left join. 


6 Replies
MichaelHansen
Posts: 149
 MichaelHansen
July 2, 2018 10:10 am
(@michaelhansen)
Estimable Member
Joined: 6 years ago

My Guess: When it returns NULL, it fails your conditions tab, so you don't get a row at all. Conditions don't accept NULL unless you specify the option. I would try toggling them off and on. You can use isnull() to get around those values or just add a line that checks for nullity.


Reply
Tim Rodman
Posts: 3199
 Tim Rodman
Admin
July 3, 2018 12:58 am
(@timrodman)
Famed Member
Joined: 10 years ago

I think you want to move your last condition into the join itself so that if it fails it won't kill your whole dataset, only the data from the table on the other side of the join.


Reply
Royce Lithgo
Posts: 557
 Royce Lithgo
Topic starter
July 3, 2018 1:31 am
(@roycelithgo)
Honorable Member
Joined: 6 years ago
Posted by: Michael Hansen

My Guess: When it returns NULL, it fails your conditions tab, so you don't get a row at all. Conditions don't accept NULL unless you specify the option. I would try toggling them off and on. You can use isnull() to get around those values or just add a line that checks for nullity.

Had the same theory and did try that, but still no rows returned.

https://imgur.com/BlG5cMk


Reply
Royce Lithgo
Posts: 557
 Royce Lithgo
Topic starter
July 3, 2018 1:47 am
(@roycelithgo)
Honorable Member
Joined: 6 years ago
Posted by: Tim Rodman

I think you want to move your last condition into the join itself so that if it fails it won't kill your whole dataset, only the data from the table on the other side of the join.

I had that theory and tried it previously, but i just found out that i made a mistake. For some reason, in the relations tab you have to use the internal Account ID value. In the Conditions tab, you can use the AccountCD within AccountID criteria and it works. I looked up the internal Account ID value for the test accounts and it worked in both cases (ie. rows or no rows on right table). 

But now the issue is trying to join the GL.Account table to an already left Joined table without killing the query. If I used an inner join between my already left joined table and the GL.Account table, i get no rows. If I use one of the outer joins, I get too many rows. At the moment the only way it would work is to use the internal Account ID value in the query.


Reply
Tim Rodman
Posts: 3199
 Tim Rodman
Admin
July 4, 2018 3:13 pm
(@timrodman)
Famed Member
Joined: 10 years ago

That's right. AccountID is a database-generated integer value that uniquely identifies the GL Account but that you don't see in the application. AccountCD is the actual GL Account number that you can see within Acumatica. You want to use AccountID in joins.

Do you need to join to Account twice, once from chgstockhist and once from stockhist? I can't see any reason why you wouldn't be able to do this as long as you use AccountID in the joins.


Reply
Royce Lithgo
Posts: 557
 Royce Lithgo
Topic starter
July 4, 2018 9:26 pm
(@roycelithgo)
Honorable Member
Joined: 6 years ago

Both tables needed to join to Account because they look for different values AccountCD. I couldn't get it to work but i think i probably should have done:

stockhist inner account1

stockhist left chgstockhist

chgstockhist left account2

The logic being that the required account in chgstockhist may not have any data and if so, i still want the stockhist row. Can't remember if i tried this or not, but i wasn't able to get it working.

Anyway, I found a much better approach for the solution and so this query was abandoned. Thanks for your help 🙂


Reply
Tim Rodman reacted
Forum Jump:
  Previous Topic
Next Topic  
Forum Information
Recent Posts
Unread Posts
Tags
  • 12 Forums
  • 2,528 Topics
  • 10.9 K Posts
  • 13 Online
  • 2,412 Members
Our newest member: Peter Paasch
Latest Post: Tax on Inventory Transfer
Forum Icons: Forum contains no unread posts Forum contains unread posts
Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed

Online Members

 No online members at the moment

Acumatica Forums

Terms of Use & Disclaimers :: Privacy Policy

Copyright © 2026 · AUG Forums, LLC. All rights reserved. This website is not owned, affiliated with, or endorsed by Acumatica, Inc.

‹›×

    ‹›×