This query has been driving me crazy, and would be grateful for a
nudge in the right direction. Still pretty much a beginner using
Access 2003, I just cannot figure the solution to the following in the
query design grid.
I have 4 tables:
tblApplicant Person
Person ID PK
tblCourses Applied
CourseAppID PK
Course ID FK
Person ID FK
Date Created
tblCompendium
Course ID PK
Course Name (text)
tblInterview
InterviewID PK
PersonID FK
Interview Outcome
As you would expect one applicant may apply for 1 or more courses.
However once interviewed they will be given an interview outcome based
their first choice of course. As they can only go on to enrol on one
course.
I need to able to create a query that returns the following fields;
Person ID
Course ID (but only for the first CourseAppID. EG their first choice
of couse)
Course Name
Interview Outcome (text)
I have tried using 'First' in the totals field of the QBE, but I dont
think this is the correct use of this. I would really appreciate a
nudge in the right direction.
Many thanks
Carl 6 9649
Use a subquery to select what their first choice is. You can then build
another query based on the results to get all the other fields you want.
The first query will be something like this (though I'm not clear how you
choose the "first" choice):
SELECT [tblApplicant Person].*,
(SELECT TOP 1 [Course ID]
FROM [tblApplication Person]
WHERE [tblApplication Person].[Person ID] =
[tblApplication Person].[Person ID]
ORDER BY [tblApplication Person].[Date Created],
[tblApplication Person].CourseAppID)
FROM [tblApplicant Person];
If subqueries are new, see: http://allenbrowne.com/subquery-01.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"zack" <za******@yahoo.co.ukwrote in message
news:11********************@b75g2000hsg.googlegrou ps.com...
This query has been driving me crazy, and would be grateful for a
nudge in the right direction. Still pretty much a beginner using
Access 2003, I just cannot figure the solution to the following in the
query design grid.
I have 4 tables:
tblApplicant Person
Person ID PK
tblCourses Applied
CourseAppID PK
Course ID FK
Person ID FK
Date Created
tblCompendium
Course ID PK
Course Name (text)
tblInterview
InterviewID PK
PersonID FK
Interview Outcome
As you would expect one applicant may apply for 1 or more courses.
However once interviewed they will be given an interview outcome based
their first choice of course. As they can only go on to enrol on one
course.
I need to able to create a query that returns the following fields;
Person ID
Course ID (but only for the first CourseAppID. EG their first choice
of couse)
Course Name
Interview Outcome (text)
I have tried using 'First' in the totals field of the QBE, but I dont
think this is the correct use of this. I would really appreciate a
nudge in the right direction.
Many thanks
Carl
Zack,
Depending on your exact result needs, you can accomplish your
requirement a couple of ways. If you really only want ONE record to
be returned, use the MIN([Date Created]), assuming this is the field
that determines which course was chosen as a first choice. If you want
all records, but need the first choice to be at the top, you can sort
your query results using the ORDER BY clause (Sort: if you are using
query designer). If you sort by [Date Created] Ascending, the
earliest date will be first in the record set. If you are also
pulling more than one individual in your results, just sort by the
[Person ID] then the [Date Created]. You can sort and limit your query
results by this date, even if you do not want the date to be part of
the query results by unchecking the Show checkbox for that field.
Hope this helps you solve your dilemma. Good luck!
- GH
On Mar 15, 7:06 am, "zack" <zack6...@yahoo.co.ukwrote:
This query has been driving me crazy, and would be grateful for a
nudge in the right direction. Still pretty much a beginner using
Access 2003, I just cannot figure the solution to the following in the
query design grid.
I have 4 tables:
tblApplicant Person
Person ID PK
tblCourses Applied
CourseAppID PK
Course ID FK
Person ID FK
Date Created
tblCompendium
Course ID PK
Course Name (text)
tblInterview
InterviewID PK
PersonID FK
Interview Outcome
As you would expect one applicant may apply for 1 or more courses.
However once interviewed they will be given an interview outcome based
their first choice of course. As they can only go on to enrol on one
course.
I need to able to create a query that returns the following fields;
Person ID
Course ID (but only for the first CourseAppID. EG their first choice
of couse)
Course Name
Interview Outcome (text)
I have tried using 'First' in the totals field of the QBE, but I dont
think this is the correct use of this. I would really appreciate a
nudge in the right direction.
Many thanks
Carl
>
Depending on your exact result needs, you can accomplish your
requirement a couple of ways. If you really only want ONE record to
be returned, use the MIN([Date Created]), assuming this is the field
that determines which course was chosen as a first choice. If you want
all records, but need the first choice to be at the top, you can sort
your query results using the ORDER BY clause (Sort: if you are using
query designer). If you sort by [Date Created] Ascending, the
earliest date will be first in the record set. If you are also
pulling more than one individual in your results, just sort by the
[Person ID] then the [Date Created]. You can sort and limit your query
results by this date, even if you do not want the date to be part of
the query results by unchecking the Show checkbox for that field.
Hope this helps you solve your dilemma. Good luck!
- GH
>
This query has been driving me crazy, and would be grateful for a
nudge in the right direction. Still pretty much a beginner using
Access 2003, I just cannot figure the solution to the following in the
query design grid.
I have 4 tables:
tblApplicant Person
Person ID PK
tblCourses Applied
CourseAppID PK
Course ID FK
Person ID FK
Date Created
tblCompendium
Course ID PK
Course Name (text)
tblInterview
InterviewID PK
PersonID FK
Interview Outcome
As you would expect one applicant may apply for 1 or more courses.
However once interviewed they will be given an interview outcome based
their first choice of course. As they can only go on to enrol on one
course.
I need to able to create a query that returns the following fields;
Person ID
Course ID (but only for the first CourseAppID. EG their first choice
of couse)
Course Name
Interview Outcome (text)
I have tried using 'First' in the totals field of the QBE, but I dont
think this is the correct use of this. I would really appreciate a
nudge in the right direction.
Many thanks
Carl- Hide quoted text -
- Show quoted text -
Many thanks for the suggestions.
Your correct I am looking for 1 applicant, 1 course (their first
choice, using data created) and 1 interview outcome.
I am still stuck as 'Min' is still bringing back all the applicants
course choices.
Any other suggestions to move forward with this. for the sake of my
sanity HELP!!
On Mar 15, 12:06 pm, "zack" <zack6...@yahoo.co.ukwrote:
I am looking for 1 applicant, 1 course (their first
choice, using data created) and 1 interview outcome.
How do you determine the applicant's first choice course? Shouldn't
there be a column in the tblInterview table to show this?
Jamie.
--
Zack,
If I am understanding correctly, your query is missing one last
element, which is a parameter or that narrows down to the selected
applicant. If you are accessing the query through a form, the form
can filter on the Person ID. If you are manually inputting a person's
ID, you can just add a WHERE clause that prompts the user for Person
ID. A simplistic test of this is to add WHERE [Person ID] = ? and
Access will prompt the user to enter the value for ?, then only the
record for the entered person would be included in the recordset.
If the issue is actually that you are getting all records for a single
applicant, this could be due to the need to make sure your criteria
has the [Date Created] = to the Min([Date Created]). This will ensure
only one course record returns, the one with the minimum date.
Alternatively, you can use Allen Browne's suggestion because it pulls
only the first record, and sorting by date ensures the earliest date
is the first record.
- GH
>...
Many thanks for the suggestions.
Your correct I am looking for 1 applicant, 1 course (their first
choice, using data created) and 1 interview outcome.
I am still stuck as 'Min' is still bringing back all the applicants
course choices.
Any other suggestions to move forward with this. for the sake of my
sanity HELP!!- Hide quoted text -
- Show quoted text -
I forgot to add that if the same create date is possible for a single
person, you could still get too many records using MIN, but you might
not necessarily get the correct record using Top 1 either if there is
no way to differentiate which course actually got created first.
- GH
On Mar 15, 8:06 am, "zack" <zack6...@yahoo.co.ukwrote:
>
...
Many thanks for the suggestions.
Your correct I am looking for 1 applicant, 1 course (their first
choice, using data created) and 1 interview outcome.
I am still stuck as 'Min' is still bringing back all the applicants
course choices.
Any other suggestions to move forward with this. for the sake of my
sanity HELP!!- Hide quoted text -
- Show quoted text -
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rick |
last post by:
Hi all,
Is there a MySQL function to get the first record through a query? I would like to open a page of
client records with the first one...
|
by: KENNY L. CHEN |
last post by:
Dear experts,
I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO)
and TEST1 (COL1,COL2,REC_NO).
Both tables are unique-indexed...
|
by: MS |
last post by:
Access 97
I want to requery the data being displayed on a form, then I want to return
to the record I was in.
Why doesn't this code work?
...
|
by: David |
last post by:
Hi,
I have a problem with returning a value from an external function.....
My asp page is basically a list taken from a database.
A date...
|
by: jennk |
last post by:
i am working in Access 97, our database tables are linked from ODBCsqlsvr (not even sure what that means). i have a table where each record has a...
|
by: Wayne |
last post by:
Is there a workaround to the bug that loses the first record in a
continuous form after using the scroll wheel if the available records
don't fill...
|
by: brucedodds |
last post by:
My application has a form based on a parent table with a subform based
on a child table. The relationship is Cascade Delete. The first
record...
|
by: Zwoker |
last post by:
Greetings everyone,
I have a problem that I hope has a simple solution. I am using MS Access 2003.
I have a table that is a list of financial...
|
by: Wildster |
last post by:
Hi,
I’ve setup a table which contains records with multiple duplicated time fields (tblTime_Slots)
i.e.
ID Time_Slot
1 08:00
2 ...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
| |