Find Intersection Of Two Queries
Jun 12, 2014I would like to find the intersection of two queries. Is the SQL keyword INTERSECT supported in Access?
View RepliesI would like to find the intersection of two queries. Is the SQL keyword INTERSECT supported in Access?
View RepliesHi-
I am developing a database for my company and I am having a hard time setting it up correctly. Basically, there will be a user who logs in to complete reviews about employees who are on a project.
I have a form which has a listbox. The listbox loads all the projects the employee is assigned to. There will be ONE review per employee per project they are assigned. Right now, when the user dbl clicks the project listed in the box, it will load the evaluation form. Now, this is what I want to happen. I want the user to dbl click the listbox. When this happens, I want it to check if there is a review already completed. If there is, then load that record into the evaluation form. If there is not a review, I want it to prompt the user to complete one. "Do you wish to create a new review?" (Yes/No) If yes, load a blank evaluation form, create a new record in the Review table to be filled out.
I can handle the VBA code for most of the form stuff, however I am having a hard time arranging my tables correctly. I have attached my current relationships.
Any help would be greatly appreciated or suggestion for approach. If you need more information, please let me know. Thank you so much.
S
I'm trying to find the intersection of recordsets that result from two SELECT queries, but (to the best of my meager knowledge) Access doesn't support the INTERSECT clause.
Are there alternative ways to perform this operation in a single query? I read a few posts that suggested LEFT JOIN, but I am not sure about how to combine a left join w/ the inner joins I am using to retrieve my data.
My SQL statement would read as follows if Access supported INTERSECT:
~~~~
SELECT * FROM
(Table1 INNER JOIN Table2 On Table1.A = Table2.B)
INNER JOIN Table3 ON Table2.C = Table3.D
WHERE (Table1.X = True) AND (Table3.Y = True)
INTERSECT
SELECT * FROM
(Table1 INNER JOIN Table2 On Table1.A = Table2.B)
INNER JOIN Table3 ON Table2.E = Table3.D
WHERE (Table1.X = True) AND (Table3.Y = True)
~~~~
I have been working on a simple data base for some time now (beginner level) and am still trying to improve it. I would like to do something but before that I would like to have your opinion to know if it is even possible?I have a query QryMainReport:
Start Date/Time
End Date/Time
Employee
At the moment this is what the format of my report looks like (I removed other unnecessary fields):
StartTime----------EndTime---------------Employee
12/06/2014 01:00--12/06/2014 03:00------John Smith
12/06/2014 04:00--12/06/2014 06:00------Jane Doe
13/06/2014 02:00--13/06/2014 05:00------John Smith
13/06/2014 08:00--13/06/2014 08:00------Jane Doe
I would like to do as a report. (Dates would always be from Sunday to Saturday). I am not sure it is possible to do that. I suppose first it would mean:I would have to do a query to separate the times from the dates?I would have to find a way for Access to find the unique dates and unique names?Does it mean I have to use cross tab queries?
Ok this might be a really stupid question, but in the quest to always make my life a little bit easier thought i would ask !
I have been asked to find the relationship between a number of tables and queries, so that this company can find out which tables and fields in tables are no longer really used, in other words how many queries and which ones is table A used in if you understand what I mean !
doing it manually means checking every query (and there are a lot !!) and seeing which table they use.. what I want to know is what is the quickest way to to this? can I do it from the table end? in others find out how many queries Table A is used in ? or do I have to go through each query individually? if this is the case my thoughts were just on copying and pasting the sql view from every query into a a word or txt doc and then doing a search /find for each table name? but if anyone has a more efficient idea on how to do this if u cld let me know !! :confused:
Hi am a forensics student taking a course in Database management and we use microsoft access 2003. I opened an assignment already started in 03 format, I am now running access 2007 and I need to make modifications to a previous query but I can't find the query table. how do I view my pre made queries on the 2007 version?
View 2 Replies View RelatedI would like to find the largest value for each row in a query. I have a query with several fields, each field has an expression that produces an integer.
Max and DMax seem to pertain to the values in a single field; I need to evaluate values from multiple fields in a single row.
I keep seeing 'range' mentioned but I have yet to see any examples of evaluating a series of data like 'col1;col2;col3' or anything remotely similar.
Say i have a table which contains payment information for various people - similar to this
Person Pay Date Pay Amount
User1 01/01/13 £10
User2 01/01/13 £10
User1 10/01/13 £0.00
User1 15/01/13 £0.00
I need to create a query which shows me only results for each person who has paid £0.00 more then once...
I've inherited a database with many queries (most based on a single table). There is a requirement to change the name of a few fields in the table. Is there a way to find ALL queries/reports that are utilizing the fields that need to be changed so I know what queries need to be modified?
View 3 Replies View RelatedI've got two tables, both are indexed by customer ID, with a series of dates against the customer ID. One has a list of all dates a customer was visited, the other is a list of dates where activity happened on the customer account
I want to get a list of the dates when the customer was visited but where no activity happened on the customer account, i.e. where there is a customer visit date on the customer visit table but no record for that date on the activity table.
How do I do that? I can find all dates where was a date was on both tables, but how to find where its on one but not the other
I am trying to find company matches between 2 tables. The issue I have is that the spellings on table A differs from table B.Some of the differences are minimal like "St. Annes" and "St Annes". And some really big "St. Annes" and "Annes, ST London".
View 1 Replies View RelatedI have a table 45 fields. There is a field ID. I would like to get the records where fields contains "No". I would not like to create 45 queries for each field check. how can i generate a table which shows ID, Field Name that contains value "No".
View 4 Replies View RelatedTrying to parse first two sections of a five section string. Now getting a SYNTAX COMMA ERROR. Th Left((([ArborID],InStr([ArborID],"-")+1,(InStr(InStr ([Arbor ID],"-")+1,[ArborID],"-")-InStr([ArborID],"-"))-1)),10)
View 14 Replies View RelatedI have the two tables in my access DB:
Property Information
Lease Information
I need to write a query which shows where a property does not have an associated lease, or where there is no current lease associated with it.
Property Info:
PropertyID
Address
Lease Info:
LeaseID
LeaseStartDate
LeaseEndDate
PropertyID (linked field to property table)
How to show expired / not current leases, but can't seem to show where there has never been a lease on a property.
I have a database with 8 years of info on customers orders. I need to find out when each customer first used our services.
View 8 Replies View RelatedHow to find the Minimum value of a column. This is my SQL:
SELECT *
FROM tblFinalMaster
WHERE (((tblFinalMaster.OperatingDay)=[forms]![frmEnterParameters]![Combo13]) AND ((tblFinalMaster.[Checkout Order])=([Forms]![frm01ATFTieLineCheckout]![Checkout Order])+2) AND ((tblFinalMaster.[From BA_REPORT])=[forms]![frmEnterParameters]![Combo5]) AND ((tblFinalMaster.[TO BA_REPORT])=[Forms]![frmEnterParameters]![Combo3]));
The part in blue, instead of pulling a +2, I want the Minimum value. Seems simple enough.
I have been trying to get this to work for days and I cant get it to work correctly. I have a query that I need to search only for the records that have 12,22 and 24 so in the fields criteria I have been trying
Total: Where
Criteria: In (12,22,24)
and it works BUT it only works for the first record it finds then it seems to skip and continue to search for all records after that.
I am not sure if my coding is efficient or not but it takes so long to read lets say tbCOMPANY 40k records and find if values of two columns exists in tbRESULT which holds 30k records. Then if it doesn't find any records in the tbRESULT it will just insert the row otherwise an update will be executed.
What I did was:
1. Read tbCOMPANY each row using for loop
2. tbCOMPANY.FindFirst to lookup if values exists in the tbRESULT
3. If tbCOMPANY.noMatch, it will insert into tbRESULT
4. else it will update the matched row in the tbRESULT
Its been taking like over 30 minutes to process this and still ongoing and it will still keep on running. Now Access is showing as Not Responding in the task manager.., Any efficient way to do this?
I'm currently busy with something for my thesis as a student and I need to use Access for this. I'm not too new at access, I know how to do the very basics, let's say on the level of [if field contains *"text*", return x].
However I am struggling right now on something that shouldn't be too hard... I could do it immediately in Excel if there werent millions of rows..I have 2 tables. Table 1 regards a list of patent publication numbers (eg. WO2012024604A3) and additional data (publication date, title, etc), only the publication number matters for me now.
Code:
Table 1
publication numberWO2011085209A2
WO2011100754A1
WO2011112983A3
EP2342192A4
EP2342192A2
EP2205725A2
EP2205725A4
WO2012006540A3
WO2010008486A3
WO2012083136A1
Table 2 contains another list of patents that might cite/refer to Table 1's patents and additional data such as publication date.
Code:
Table 2
Publication Number Citing PatentsPublication Date Cited Refs - Patent
AU2001287375B2 1998-12-01 US5178882A | US4225581A | WO1998001161A2
AU2001288365B2 1990-02-24 US5967154A | WO1996039117A2 | US3699979A | US3943949A | US3838702A
AU2001288437B2 1999-03-09 US6087157A
[code]....
Now what I'd like to do is to create a third table which has for each of [Table 1].[Publication number]:
Column 2) A count of how many times the [Table 1].[Publication number] is found in [Table 2].[Cited Refs - Patent] ...
Column 3) In case a patent is cited more than once, return the [table 2].[publication Number Citing Patents] value of the earliest citing patent (so with the lowest Publication Date value).
For Column 2 I had expected it to be an easy count(iif( [Table 2].[Cited Refs - Patent] = "*"&[Table 1].[publication number]&"*")) command but apparently it's harder than that..
I've got 2 tables, same structure, one [T-temp-Target] holds number of training units split by module a trainee needs to finish the course, the other [T-temp-Actual] holds what they've completed so far.
Both tables have structure
TRAINEEID
MODCODE
CountOfUnits
I'm trying to find the modules that they've not done yet so I can add up the units for them, only modules that have been started are recorded in the table of what they've done [T-temp-Actual], modules they haven't started yet aren't included in it. Here's the SQL
Code:
SELECT
[T-temp-Target].TRAINEEID,
[T-temp-Target].MODCODE,
[T-temp-Actual].MODCODE
FROM [T-temp-Actual] INNER JOIN [T-temp-Target] ON
([T-temp-Actual].TRAINEEID = [T-temp-Target].TRAINEEID) AND
([T-temp-Actual].MODCODE = [T-temp-Target].MODCODE)
WHERE ((([T-temp-Actual].MODCODE) Is Null));
I need to find all MaintItems which field MIC don't exist in either MIC1 or MIC2. So the only result which I need to see is MaintItem '5100161086' as MIC <> MIC1 Unfortunately I can create query which would approve '5100662734' as well
MaintItem ------MIC------ MIC1 ------ MIC2
5100634036 50000173 50000173
5100662790 50000174 50000174
5100662734 50000145 50000145 50000180
5100662734 50000180 50000145 50000180
5100161086 500001711 50000173
So bottom line I need a query which will display only the row below as MIC doesn't exist in neither MIC1 nore MIC2. Also I will have to deal with much more MICs soon so maybe there is a way to concatenate them and compare, isn't it? 5100161086 500001711 50000173
Attached query is what I got so far, but that displays last 3 rows of table above
I am trying to create a query and in the expression builder to find the max value from 3 different fields in 3 other queries.So each of the fields are called "TopSpeed" and the 3 queries are called "Test", "Training" & "Race".So in my new query I would like to return the MAX speed value from the 3 combined "TopSpeed" fields.Something like
MAX(DMAX([TopSpeed], [Test]), DMAX([TopSpeed], [Training]), DMAX([TopSpeed], [Race]))
I have a list of project, each of which have dates which work were carried out on them. Each project can have more than one date. I want to be able to find the last date that any work was carried out, and then calculate how many days have passed since that happened.
View 6 Replies View RelatedI am managing a tool room and one of my tasks is to update a chit board where people sign out their tools. I have managed to make a query to find New Employees and one to find Terminated Employees. I have also made a query to find the matching employees between these two queries.
My problem is that we employ both contractors and direct employees. When a contractor is hired on directly, their name shows up in both the New list and the Terminated list.What I want to do is have a separate query that shows contractors who went direct and not have these employees show up in the other 2 queries.
Both queries are unmatched query that compare the "Current Chit Board" table to the "Weekly Roster Check" table. The first query called "New Employees" displays the data from the "Weekly Roster Check" table where Employee Number from "Current Chit Board" Is Null. The second query called "Terminated Employees" is the exact oposite. The third query I have is called "Contract to Direct" compares the "New Employees" query to the "Terminated Employees" Query with a "fields from both tables are equal" join type.The problem is when I try to do an unmatched between either the New or Terminated Emplyees queries and the Contract to Direct query, I get a Circular Reference warning and it doesn't execute.
I am attempting to build a small database for my firm to keep a track of equipment. The equipment can be in one of three places. In the warehouse, out on a job or at the repairers. I want to create a query that will let me know where a piece of equipment is at any one time. I'm sure my tables are set up correctly. I have use a union query to work out when equipment is on a job or in repairs but I need one to show me where all the equipment currently is.
View 1 Replies View Relatedi have created a parameter query which will find a students best and worst time for each exercise they have done. so you enter the student ID when you run the query and it works fine but i have a problem i need to query to find two students in particular and then i have to create a report from this query on the two students identified and this is where i come up stuck. i have tried typing in both student id's into the criteria but this doesnt work no matter if i put and in it or not and im not sure how to get the job done.
View 7 Replies View Related