Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8432197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:03:51+00:00 2026-06-10T06:03:51+00:00

Im trying to create a calculation in Access through the use of queries. At

  • 0

Im trying to create a calculation in Access through the use of queries. At the moment one query calculates the value of ‘MPP Oil’ (max production potential) and another query needs to use this value to calculate ‘Unallocated losses’. These calculations use company/asset/year data from a base query ‘PEBaseQuery’. Other input values to calculate Unallocated losses are referenced using IDs… There seems to be something off with my code though, please help!

SELECT 
    qb1.CompanyName, 
    qb1.AssetName, 
    qb1.Year, 
    (qb3.MPPOilRevised 
     - SUM(qb1.DatapointValue) 
     - SUM(qb2.DatapointValue * 1000000)) AS Result
FROM 
    ((PEBaseQuery AS qb1 
    INNER JOIN PEBaseQuery AS qb2 
    ON qb1.Year = qb2.Year AND qb1.AssetName=qb2.AssetName)
    INNER JOIN PE_MPPOilRevised AS qb3 
    ON qb1.Year = qb3.Year AND qb1.AssetName=qb3.AssetName)
WHERE 
    qb1.DatapointID in (2033, 2035, 2043, 2037, 2031) 
AND qb2.DatapointID=2003
GROUP BY qb1.CompanyName, qb1.AssetName, qb1.Year;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:03:53+00:00Added an answer on June 10, 2026 at 6:03 am

    From the error you mentioned in the comments:

    the error ‘You tried to execute a query that does not include the specified expression ‘CompanyName’ as part of an aggregate function’

    Use of aggregate functions require you to group by the columns that appear in the SELECT list other than the aggregated columns.

    Edit:

    I think this is what you are looking for:

    SELECT
        qb1.CompanyName, 
        qb1.AssetName, 
        qb1.Year, 
        qb3.MPPOilRevised - TotalDataPointValue - TotalDataPointValueFactor
    FROM
        ((
            SELECT 
                qb1.CompanyName, 
                qb1.AssetName, 
                qb1.Year, 
                SUM(qb1.DatapointValue) 'TotalDataPointValue',
                SUM(qb2.DatapointValue * 1000000) 'TotalDataPointValueFactor'
            FROM 
                (PEBaseQuery AS qb1 
                INNER JOIN PEBaseQuery AS qb2 
                ON qb1.Year = qb2.Year AND qb1.AssetName = qb2.AssetName)
            WHERE 
                qb1.DatapointID in (2033, 2035, 2043, 2037, 2031) 
            AND qb2.DatapointID = 2003
            GROUP BY qb1.CompanyName, qb1.AssetName, qb1.Year
        ) qb1
        INNER JOIN PE_MPPOilRevised AS qb3 
        ON qb1.Year = qb3.Year AND qb1.AssetName=qb3.AssetName)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use one file to create a menu in the command
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I am trying to perform a calculation on multiple values in the value portion
I am trying to create an md5 value in php using the instruction given.
I'm trying to create a MySQL statement that will sort by a value calculated
I'm trying to find a way to create a calculation from results in a
I'm trying to create a function to calculate the mean, max, min and standard
I am trying to take the output from my ICC calculation and create a
I'm trying to create a calculation based on the values of the array -
I'm trying to create to use a table as a look-up table. Normally, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.