Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

need help with an Access query

Posted on 2011-03-03
18
257 Views
Last Modified: 2012-05-11
Please see attached example.

I want a list of all the award numbers in table 1 that do not have a match in table 2.  But I want Access to only search awards in table 2 that have calendar year 2009, calendar quarter 3, and last update 10/1/2009.  In this example, the list would include award numbers:  xoexf, eisld, and clien.  

I want a query where I can simply change the year, quarter, and last update and get a new list, based on those parameters.  Is this possible or do I have to separate table 2 into a table for each date within the last update field and do separate queries?
example.xlsx
0
Comment
Question by:nblassen
  • 8
  • 7
  • 3
18 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35028850
select T1.awardnumber
table1 As T1 left join Table2 as T2
on T1.awardnumber=t2.awardnumber
where T2.year=2009 and t2.quarter=3 and t2.lastupdate=#10/1/2009# and
t2.awardnumber is null
0
 
LVL 77

Expert Comment

by:peter57r
ID: 35028886
You need to create a saved query that does the selection from table2; you can use parameters for the criteria if you wish.

You can then then use the Find Unmatched query wizard , starting from table1 and using the saved query as the second table.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 35028936
Cap1- a rare day this is, but that SQL won't work Im afraid.  
The selection from table2 will destroy the Left join and convert it into an Inner join.

0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:nblassen
ID: 35028975
peter57r - you're right. It didn't work.  I had tried it before as well.  Do you have an alternative solution?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35029064


try this then,

select T1.awardnumber
table1 As T1 left join
(select t2.awardnumber, t2.[year],t2.lastupdate from Table2 as T2
where T2.year=2009 and t2.quarter=3 and t2.lastupdate=#10/1/2009#
) as t3
on T1.awardnumber=t3.awardnumber where
t3.awardnumber is null
0
 
LVL 77

Expert Comment

by:peter57r
ID: 35029111
"Do you have an alternative solution? "

in addition to the one i already posted ?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35029127
oops...


try this then,

select T1.awardnumber
from table1 As T1 left join
(select t2.awardnumber, t2.[year],t2.lastupdate from Table2 as T2
where T2.year=2009 and t2.quarter=3 and t2.lastupdate=#10/1/2009#
) as t3
on T1.awardnumber=t3.awardnumber where
t3.awardnumber is null
0
 

Author Comment

by:nblassen
ID: 35029298
Sorry peter57r, forgot you had already posted a solution.  Thank you.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35029362
nblassen,
did you try the query posted at http:#a35029127
0
 

Author Comment

by:nblassen
ID: 35029472
capricorn1:
Yes, I did, but I can't seem to get it to work.  I'm a novice user.  What is T3 in your example?  Do I need to create another table?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35029497
<Do I need to create another table?>  No
you will use the two tables that you have..

post the sql statement of the query you are using..

or upload a copy of the db
0
 

Author Comment

by:nblassen
ID: 35029990
SELECT [Table 1].[AWARD NUMBER], [Table 2].CALENDAR_YEAR, [Table 2].CALENDAR_QUARTER, [Table 2].TIME_STAMP_OF_LAST_UPDATE
FROM [Table 1] LEFT JOIN [Table 2] ON [Table 1].[AWARD NUMBER]=[Table 2].AWARD_NUMBER
WHERE ((([Table 2].AWARD_NUMBER) Is Null) AND (([Table 2].CALENDAR_YEAR)=2009) AND (([Table 2].CALENDAR_QUARTER)=3) AND (([Table 2].TIME_STAMP_OF_LAST_UPDATE)=#10/1/2009#));
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35030048
what fields do you want to see in the result?
0
 

Author Comment

by:nblassen
ID: 35030077
I want to see the award number from Table 1.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35030146
copy and paste this in the SQL view of a new query


SELECT T1.[AWARD NUMBER]
FROM [Table 1] As T1 LEFT JOIN
(Select T2.CALENDAR_YEAR, T2.CALENDAR_QUARTER, T2.TIME_STAMP_OF_LAST_UPDATE From [Table 2] as T2 WHERE T2.CALENDAR_YEAR=2009 AND T2.CALENDAR_QUARTER=3 AND T2.TIME_STAMP_OF_LAST_UPDATE=#10/1/2009#) As T3
ON T1.[AWARD NUMBER]=T3.AWARD_NUMBER
WHERE T3.AWARD_NUMBER Is Null

0
 

Author Comment

by:nblassen
ID: 35030247
I pasted it into the SQL view, but when I tried to run it, a pop up box appeared that said Enter Parameter Value, T3.Award_Number.

0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 35030298
oops, try this one


SELECT T1.[AWARD NUMBER]
FROM [Table 1] As T1 LEFT JOIN
(Select T2.AWARD_NUMBER,T2.CALENDAR_YEAR, T2.CALENDAR_QUARTER, T2.TIME_STAMP_OF_LAST_UPDATE From [Table 2] as T2 WHERE T2.CALENDAR_YEAR=2009 AND T2.CALENDAR_QUARTER=3 AND T2.TIME_STAMP_OF_LAST_UPDATE=#10/1/2009#) As T3
ON T1.[AWARD NUMBER]=T3.AWARD_NUMBER
WHERE T3.AWARD_NUMBER Is Null
0
 

Author Comment

by:nblassen
ID: 35030424
It worked!  Thanks for all your help!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question