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

The Archive Base Latest Questions

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

Name ExactDate Presents Location bob1 2011 1 home bob2 2008 2 school bob2 2012

  • 0
Name      ExactDate  Presents      Location
bob1         2011        1          home
bob2         2008        2          school     
bob2         2012        3          school
mary2        1986        4          school       
mary1        2001        5          home
mary1        2012        6          home    
kate1        2011        7          home
kate1        2012        8          home
kate2        2011        9          school 
celia2       2011       10          school 
celia2       1986       11          school  
celia1       1972       12          home
celia1       2012       14          home 
celia2       2012       13          school

This problem is done in SQL in MS Access 2003 for a query.

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 receive 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        PresentsDiff
celiaminuskate     2011                      3
celiaminuskate     2012                      6

So far I have :

SELECT 'celiaminuskate'AS [NAME],T1.[date] AS [EXACT DATE],
T1.presents T2.presents AS [PRESENTS DIFF]
FROM Some_Table T1, Some_Table T2 

part that I think needs to be fixed??

WHERE (T1.Name = 'celia1'>'celia2')
AND (T2.Name = 'kate1'>'kate2')
AND T2.ExactDate = T1.ExactDate 

to indicate priority? I’m not too sure how to do it

ORDER BY T1.ExactDate
  • 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:36:33+00:00Added an answer on May 24, 2026 at 1:36 am

    I created this query and saved it as qryCeliaAndKateGiftDates. It just returns the distinct ExactDate values for which celia and kate both had gifts recorded.

    Notice I re-named your Name field to Recipient, because Name is a reserved word.

    SELECT DISTINCT celia.ExactDate
    FROM
        [SELECT ExactDate
        FROM Some_Table
        WHERE Recipient Like "celia*"
        ]. AS celia
        INNER JOIN [
            SELECT ExactDate
            FROM Some_Table
            WHERE Recipient Like "kate*"
            ]. AS kate
        ON celia.ExactDate = kate.ExactDate
    ORDER BY celia.ExactDate;
    

    Then I used correlated subqueries to return the correct Presents values for celia and kate on each of those ExactDates.

    SELECT
        raw.recipients AS [NAME],
        raw.ExactDate  AS [EXACT DATE],
        (raw.celia_presents - raw.kate_presents) AS [PRESENTS DIFF]
    FROM
        [SELECT
        'celiaminuskate' AS recipients,
        dates.ExactDate,
        (SELECT TOP 1 Presents
        FROM Some_Table
        WHERE
            Recipient Like "celia*"
            And ExactDate = dates.ExactDate
        ORDER BY Location) AS celia_presents,
        (SELECT TOP 1 Presents
        FROM Some_Table
        WHERE
            Recipient Like "kate*"
            And ExactDate = dates.ExactDate
        ORDER BY Location) AS kate_presents
        FROM qryCeliaAndKateGiftDates AS dates]. AS raw;
    

    It returns the results you requested when run from Access 2003. However correlated subqueries are notoriously slow, so I’ll be interested to see what other answers you get.

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

Sidebar

Related Questions

Name ExactDate Presents bob 2011 1 bob 2008 2 bob 2012 3 mary 1986
[ { name: John Doe, location: { name: New York, New York, id: 12746342329
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
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
SELECT name FROM sys.databases -- this can list all database name in the server
class Name implements Runnable { public void run() { for (int x = 1;

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.