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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:40:44+00:00 2026-05-24T01:40:44+00:00

Name ExactDate Presents bob 2011 1 bob 2008 2 bob 2012 3 mary 1986

  • 0
Name     ExactDate  Presents
bob      2011        1
bob      2008        2
bob      2012        3
mary     1986        4
mary     2001        5
mary     2012        6
kate     2011        7
kate     2012        8
kate     2013        9
celia    2011       10
celia    1986       11
celia    1972       12
celia    2012       13
celia    1991       14

So the goal is we subtract the amount of presents kate got from celia on the same day and out put should be something like the following:

Name              ExactDate        Presents
celiaminuskate    2011              3
celiaminuskate    2012              5

Thank you so much I am a first time user of access and SQL . and have a data management task required of me at work. so this has really go me stuck
This is done in ms access 2003 SQL



HEY SO I GOT THE FIRST PART THERE AND NOW IT GETS HARDER ASSUMING THE DATA SET IS NOW LIKE THIS

Name     ExactDate  Presents  Location
bob      2011        1          home
bob      2008        2          school     
bob      2012        3          school
mary     1986        4          school       
mary     2001        5          home
mary     2012        6          homw    
kate     2011        7          home
kate     2012        8          home
kate     2011        9          school 
celia    2011       10          school 
celia    1986       11          school  
celia    1972       12          home
celia    2012       14          home 
celia    2012       13          school

So the goal is we subtract the amount of presents kate got from celia on the same year ( but since there are a few different present values for the same year we choose to have priority of home > school….for example celia and kate both recieves presents in 2012 but celia gets both home presents and school presents in 2012 in which case we choose her home present value to do the calculation) and out put should be something like the following:

Name              ExactDate        Presents
celiaminuskate    2011              3
celiaminuskate    2012              6
  • 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-24T01:40:45+00:00Added an answer on May 24, 2026 at 1:40 am

    This should do it:

    SELECT
        'celiaminuskate' AS [NAME],
        T1.[date] AS [EXACT DATE],
        T1.presents - T2.presents AS [PRESENTS DIFF]
    FROM
        Some_Table T1
    INNER JOIN Some_Table T2 ON
        T2.[name] = 'kate' AND
        T2.[date] = T1.[date]
    WHERE
        T1.[name] = 'celia'
    ORDER BY
        T1.[date]
    

    A couple of suggestions since you’re new to SQL:

    1. Try to avoid using keywords, like “date” for column names
    2. Your “date” column looks like a year, not a date. It should be named appropriately and you should make sure that it’s the correct data type.

    Since it sounds like the version of Access that you’re using doesn’t support the now standard JOIN syntax, here is another query which should be equivalent:

    SELECT
        'celiaminuskate' AS [NAME],
        T1.[date] AS [EXACT DATE],
        T1.presents - T2.presents AS [PRESENTS DIFF]
    FROM
        Some_Table T1, Some_Table T2
    WHERE
        T1.[name] = 'celia' AND
        T2.[name] = 'kate' AND
        T2.[date] = T1.[date]
    ORDER BY
        T1.[date]
    

    T1 and T2 in this query are simply aliases for the tables in the FROM clause so that you can distinguish them.

    If you’re trying to put the results into another table then you will need this to be part of an INSERT statement. Or, with Access you might be able to use a query to generate a table as part of some wizard. I’m afraid that I don’t have a copy handy to give more specifics. In any case, here is what the INSERT statement would look like:

    INSERT INTO Some_New_Table (name, exactdate, presentsdiff)
    SELECT ...
    

    (The ellipsis just means to use the query as I have it up above)

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

Sidebar

Related Questions

Name ExactDate Presents Location bob1 2011 1 home bob2 2008 2 school bob2 2012
Table Name: MRM_BOOKING_DETAILS Sample Data: Booking_id USER_ID ROOM_ID CHECKIN CHECKOUT 1 hary 1 2012-04-16
Data: Name | Score | Date == John | 10 | 09/01/2012 John |
Name of the option tells something but what Visual Studio/compiler really do and what
Name the design considerations in deciding between use of a singleton versus a static
Name: <%= Html.TextBox(txtName, 20, new { @class = hello }) %> I want that
when name spacing models. should the containing folder's name be in plural form? i.e.
The name of a temporary table such as #t1 can be determined using select
var name = 'Mike'; var person = { name: 'John', welcome: function(){ var name
Class name: MyAssembly.MyClass+MyOtherClass The problem is obviously the + as separator, instead of traditionnal

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.