Results 1 to 4 of 4
  1. #1
    jazzy is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    77

    2 exact same queries running on 2 different databases and different results


    this one sums the RMD field
    Code:
    SELECT IRADetails.FullName, IRADetails.AccountNumber AS [Acct#], IRADetails.Age, IRADetails.AccountNumber, Sum(IRADetails.Amount) AS Amount, IRADetails.Company, [IRA RMD Table].Multiplier AS Mult, [Amount]/[Multiplier] AS RMD, IRADetails.DOB, IRADetails.Last4SSMasked, IRADetails.Automated, IRADetails.Complete, IRADetails.Scheduled, IRADetails.ScheduledDate, IRADetails.RMDTypeFROM IRADetails LEFT JOIN [IRA RMD Table] ON IRADetails.Age = [IRA RMD Table].Age
    GROUP BY IRADetails.FullName, IRADetails.Age, IRADetails.AccountNumber, IRADetails.Company, [IRA RMD Table].Multiplier, [Amount]/[Multiplier], IRADetails.DOB, IRADetails.Last4SSMasked, IRADetails.Automated, IRADetails.Complete, IRADetails.Scheduled, IRADetails.ScheduledDate, IRADetails.RMDType, IRADetails.AccountNumber
    HAVING (((IRADetails.Age)>71));
    this ones does not sum the RMD field
    Code:
    SELECT IRADetails.FullName, IRADetails.AccountNumber AS [Acct#], IRADetails.Age, IRADetails.AccountNumber, Sum(IRADetails.Amount) AS Amount, IRADetails.Company, [IRA RMD Table].Multiplier AS Mult, [Amount]/[Multiplier] AS RMD, IRADetails.DOB, IRADetails.Last4SSMasked, IRADetails.Automated, IRADetails.Complete, IRADetails.Scheduled, IRADetails.ScheduledDate, IRADetails.RMDTypeFROM IRADetails LEFT JOIN [IRA RMD Table] ON IRADetails.Age = [IRA RMD Table].Age
    GROUP BY IRADetails.FullName, IRADetails.Age, IRADetails.AccountNumber, IRADetails.Company, [IRA RMD Table].Multiplier, [Amount]/[Multiplier], IRADetails.DOB, IRADetails.Last4SSMasked, IRADetails.Automated, IRADetails.Complete, IRADetails.Scheduled, IRADetails.ScheduledDate, IRADetails.RMDType, IRADetails.AccountNumber
    HAVING (((IRADetails.Age)>71));
    any ideas?

  2. #2
    jazzy is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    77
    i changed the expression [Amount]/[Multiplier] to [Amount]/[Mult] ran the query then changed it back to [Amount]/[Multiplier] and its working fine..... is there something i am missing or is Access just that crazy?

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Firstly, I cannot see any difference in those two queries?

    You are creating an aliased field called Amount:
    Sum(IRADetails.Amount) AS Amount

    You are then using that alias in a later calculation within the same query:

    [Amount]/[Multiplier] AS RMD

    Whilst Access lets you do this I'm not convinced it in a grouped query this will work reliably.
    Better to break it down into two queries, one that produces the base results, then another one based on that, that does the subsequent sums.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Not sure why it would suddenly work after making the changes, except to say that the query plan would get rebuilt in doing so, and it might have been faulty for the reason stated. The only thing I see wrong is that there is no space before From, but that might just be a posting error.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Parameter Queries - Include rather than exact
    By templeowls in forum Queries
    Replies: 3
    Last Post: 02-28-2019, 10:10 AM
  2. Replies: 14
    Last Post: 06-27-2017, 04:52 PM
  3. Running Queries on Split Databases
    By mjaustin18 in forum Queries
    Replies: 3
    Last Post: 09-24-2014, 04:57 AM
  4. Queries using various databases
    By roemerle in forum Queries
    Replies: 4
    Last Post: 07-30-2014, 03:40 PM
  5. Replies: 3
    Last Post: 09-12-2013, 02:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums