473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

need help on simple(?) query

Hi, I have the following two tables:
1. Client Table
ID - Primary Key

2. Enrollment Table
EnrollID - Primary Key
ClientID - Foreign Key
Enroll Date
I need to find the earliest enroll date for each client, but I can't
figure out how to do this, even with subqueries.
Any tips would be much appreciated.

Nov 13 '05 #1
3 1169
On 12 Jul 2004 10:14:54 -0700, "John Fitzgerald"
<jr**********@gmail.com> wrote:
Hi, I have the following two tables:
1. Client Table
ID - Primary Key

2. Enrollment Table
EnrollID - Primary Key
ClientID - Foreign Key
Enroll Date
I need to find the earliest enroll date for each client, but I can't
figure out how to do this, even with subqueries.
Any tips would be much appreciated.

Try using First for the enrollment date. Somethin like ...

SELECT tblClient.ClientID, First(EnrollDate) AS FirstEnrolled
FROM tblClient INNER JOIN tblEnrollment ON tblClient.ClientID =
tblEnrollment.ClientID
GROUP BY tblClient.ClientID;

- Jim
Nov 13 '05 #2
Jim,

There's no guarantee this will work! First will only give you the first date
that was entered. If the first date that was entered was not the earliest date,
the returned record will not be correct.

Rather, the poster needs to use a totals query where Group By in the EnrollDate
field is changed to Min.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Jim Allensworth" <ji****@datacentricsolutions.com> wrote in message
news:40****************@news.west.earthlink.net...
On 12 Jul 2004 10:14:54 -0700, "John Fitzgerald"
<jr**********@gmail.com> wrote:
Hi, I have the following two tables:
1. Client Table
ID - Primary Key

2. Enrollment Table
EnrollID - Primary Key
ClientID - Foreign Key
Enroll Date
I need to find the earliest enroll date for each client, but I can't
figure out how to do this, even with subqueries.
Any tips would be much appreciated.

Try using First for the enrollment date. Somethin like ...

SELECT tblClient.ClientID, First(EnrollDate) AS FirstEnrolled
FROM tblClient INNER JOIN tblEnrollment ON tblClient.ClientID =
tblEnrollment.ClientID
GROUP BY tblClient.ClientID;

- Jim

Nov 13 '05 #3
On Mon, 12 Jul 2004 18:51:56 GMT, "PC Datasheet" <no****@nospam.spam>
wrote:
There's no guarantee this will work! First will only give you the first date
that was entered. If the first date that was entered was not the earliest date,
the returned record will not be correct.


Yep, you are correct Min would be better.

SELECT tblClient.ClientID, Min(EnrollDate) AS FirstEnrolled
FROM tblClient INNER JOIN tblEnrollment ON tblClient.ClientID =
tblEnrollment.ClientID
GROUP BY tblClient.ClientID;

- Jim

<Ads, etc. snipped>
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sumGirl | last post by:
Can someone demonstrate a SIMPLE way to do this that does not require additional functions or stored procedures to be created? Lets say I want to execute the following simple query - "select * from...
3
by: Don Sealer | last post by:
I'm guessing this is pretty simple however not simple enough for me. I'm developing a database to track expenses, income, banking transactions, etc. I have a very simple query with four fields,...
3
by: Water Cooler v2 | last post by:
Dang! A *simple* query doesn't run on my machine. I wrote a Data Access Layer (DAL) in a dll that I am testing with the help of a console application. Here's the code. I am damn sure that my...
3
by: prabhas | last post by:
I want to swap two tuples in a table, using a single , simple query. No SELECT query allowed, no inner queries allowed. No PL/SQL allowed. Do you have any idea how to do this? e.g. my current...
9
by: muddasirmunir | last post by:
i have a simple query and does not getting desire results which i want i am using vb6 and access i had a table with with 8 fields but just to simplyfy by question i am just supposing to four. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.