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

  • Home
  • SEARCH
  • 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 8986999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:41:09+00:00 2026-06-15T21:41:09+00:00

I have a query in MS-Access that I am trying to pull some values

  • 0

I have a query in MS-Access that I am trying to pull some values based on a condition, then sum the results.

SELECT SchedulingLog.UserID, SchedulingLog.Category, Sum(SchedulingLog.Value) AS Gain, Sum(SchedulingLog.Value) AS Used, [Gain]+[Used] AS [Left]
FROM SchedulingLog
GROUP BY SchedulingLog.UserID, SchedulingLog.Category, [Gain]+[Used]
HAVING ((
(SchedulingLog.Category) Like "DH*" Or 
(SchedulingLog.Category) Like "Com*") AND 
("Where[CatDetai]" Like "Gain*") AND 
("Where[CatDetai]" Like "Used*")
);

With these data in SchedulingLog …

Userid LogDate EventDate Category CatDetail Value
abc123  1-1-11    7-2-11 DH       DH Used      -1
abc123  1-1-11    7-4-11 DH       DH Gain       1

… I want my query to give me this result set:

Userid Category Gain Used Left
abc123 DH          1   -1    0
  • 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-15T21:41:10+00:00Added an answer on June 15, 2026 at 9:41 pm

    The following SQL returns what you asked for based on testing with your sample data in Access 2007.

    SELECT
        Userid,
        Category,
        Sum(IIf(CatDetail ALike '%Gain', [Value], 0)) AS Gain,
        Sum(IIf(CatDetail ALike '%Used', [Value], 0)) AS Used,
        [Gain] + [Used] AS [Left]
    FROM SchedulingLog
    GROUP BY
        Userid,
        Category
    

    However, if you don’t actually need to see the separate values for Gain and Used, it would be simpler to do it this way:

    SELECT
        Userid,
        Category,
        Sum([Value]) AS [Left]
    FROM SchedulingLog
    GROUP BY
        Userid,
        Category
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Django query and some Python code that I'm trying to optimize
I have some tables in Access that I'm trying to export to csv so
I have a Microsoft Access database query that I'm trying to import into a
Here is my access query that I have. Every value that I return is
I have a Maketable query in an Access db that could use an Autonumber
I have the following Access query: SELECT [city] FROM [patient] WHERE REPLACE([patient].[city],' ',' ')
I have a query that im trying to collect tallys from fields in one
So I have an awful query that current exists in MS Access that I
I have a query in SQL Server that I am trying to convert to
I have the following SQL query in MS Access. I'm trying to order the

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.