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 7179145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:04:52+00:00 2026-05-28T17:04:52+00:00

May I ask for your help with the following please ? I am trying

  • 0

May I ask for your help with the following please ?

I am trying to calculate a change from one record to the next in my results. It will probably help if I show you my current query and results …

SELECT A.AuditDate, COUNT(A.NickName) as [TAccounts],
       SUM(IIF((A.CurrGBP > 100 OR A.CurrUSD > 100), 1, 0)) as [Funded]
FROM Audits A
GROUP BY A.AuditDate;

The query gives me these results …

AuditDate D/M/Y         TAccounts     Funded                    
--------------------------------------------
30/12/2011              506           285
04/01/2012              514           287
05/01/2012              514           288
06/01/2012              516           288
09/01/2012              520           289
10/01/2012              522           289
11/01/2012              523           290
12/01/2012              524           290
13/01/2012              526           291
17/01/2012              531           292
18/01/2012              532           292
19/01/2012              533           293
20/01/2012              537           295

Ideally, the results I would like to get, would be similar to the following …

AuditDate D/M/Y         TAccounts     TChange   Funded           FChange
------------------------------------------------------------------------
30/12/2011              506           0         285              0
04/01/2012              514           8         287              2
05/01/2012              514           0         288              1
06/01/2012              516           2         288              0
09/01/2012              520           4         289              1
10/01/2012              522           2         289              0
11/01/2012              523           1         290              1
12/01/2012              524           1         290              0
13/01/2012              526           2         291              1
17/01/2012              531           5         292              1
18/01/2012              532           1         292              0
19/01/2012              533           1         293              1
20/01/2012              537           4         295              2 

Looking at the row for ’17/01/2012′, ‘TChange’ has a value of 5 as the ‘TAccounts’ has increased from previous 526 to 531. And the ‘FChange’ would be based on the ‘Funded’ field. I guess something to be aware of is the fact that the previous row to this example, is dated ’13/01/2012′. What I mean is, there are some days where I have no data (for example over weekends).

I think I need to use a SubQuery but I am really struggling to figure out where to start. Could you show me how to get the results I need please ?

I am using MS Access 2010

Many thanks for your time.

Johnny.

  • 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-05-28T17:04:53+00:00Added an answer on May 28, 2026 at 5:04 pm

    Here is one approach you could try…

    SELECT B.AuditDate,B.TAccounts,
        B.TAccount - 
        (SELECT Count(NickName) FROM Audits WHERE AuditDate=B.PrevAuditDate) as TChange,
        B.Funded - 
        (SELECT Count(*) FROM Audits WHERE AuditDate=B.PrevAuditDate AND (CurrGBP > 100 OR CurrUSD > 100)) as FChange
    FROM (
    SELECT A.AuditDate,
        (SELECT Count(NickName) FROM Audits WHERE AuditDate=A.AuditDate) as TAccounts,
        (SELECT Count(*) FROM Audits WHERE (CurrGBP > 100 OR CurrUSD > 100)) as Funded,
        (SELECT Max(AuditDate) FROM Audits WHERE AuditDate<A.AuditDate) as PrevAuditDate
    FROM
    (SELECT DISTINCT AuditDate FROM Audits) AS A) AS B
    

    Instead of using a Group By I’ve used subquerys to get both TAccounts and Funded, as well as the Previous Audit Date, which is then used on the main SELECT statement to get TAccounts and Funded again but this time for the previous date, so that any required calculation can be done against them.

    But I would imagine this may be slow to process

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There may be more than one way to ask this question, so here's a
This may not be the kind of question one should ask on StackOverflow, but
I want to ask your opinion about one specific aspect of endless Qt vs
I realize this may be subjective, so will ask a concrete question, but first,
Why you may ask? Because i have built the app on mysql and need
This may be rather noobish but I'm gonna ask anyhow. I have a class
This may sound like a bit of a rhetorical question, but I ask it
This may not be a programming question, but I don't know where to ask
This may be a stupid question, but I have to ask! I have the
I'm not a DBA so this may be a stupid question but I'll ask

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.