D
Don
This is an expansion of my original post (10/2/2005 - "Returning First (or
just one) Record").
In trying to work through what might be a solution, it dawned on me that
maybe I did not explain the question well enough. To work through the
problem, I developed a similar table construct. Hopefully someone out there
can give me a few pointers in the right direction.
"Original" table:
StudentID LastName FirstName MaleFemale Age
1 Doe Jane No 10
2 Doe Johnny Yes 9
3 Smith Suzy No 7
4 Jones Rick Yes 9
5 Doe Buck Yes 8
6 Doe Betty No 7
7 Bopp Betty No 8
8 Bear Yogi Yes 8
9 Smith Sammy Yes 8
My objective is to develop a query which, in this example, will return all
records of one sex (M or F). If there is more than one with the same last
name (I am assuming they are from the family so they are siblings) I only
want the name of the oldest sibling. So, running this "mind" query on the
above table selecting females, the result would be:
1 Doe Jane No 10
3 Smith Suzy No 7
7 Bopp Betty No 8
I have tried a variety of forms of subqueries, unions, DISTINCT and TOP, but
either end up with a single record, or all the records.
There has got to be a relatively simple solution to this, but it is truly
escaping me. (Yes, I am a relative newbie!) Another example of this type
problem would be finding the most expensive item in an order for a variety
of orders.
Any assistance will be greatly appreciated!
Thanks!
Don
just one) Record").
In trying to work through what might be a solution, it dawned on me that
maybe I did not explain the question well enough. To work through the
problem, I developed a similar table construct. Hopefully someone out there
can give me a few pointers in the right direction.
"Original" table:
StudentID LastName FirstName MaleFemale Age
1 Doe Jane No 10
2 Doe Johnny Yes 9
3 Smith Suzy No 7
4 Jones Rick Yes 9
5 Doe Buck Yes 8
6 Doe Betty No 7
7 Bopp Betty No 8
8 Bear Yogi Yes 8
9 Smith Sammy Yes 8
My objective is to develop a query which, in this example, will return all
records of one sex (M or F). If there is more than one with the same last
name (I am assuming they are from the family so they are siblings) I only
want the name of the oldest sibling. So, running this "mind" query on the
above table selecting females, the result would be:
1 Doe Jane No 10
3 Smith Suzy No 7
7 Bopp Betty No 8
I have tried a variety of forms of subqueries, unions, DISTINCT and TOP, but
either end up with a single record, or all the records.
There has got to be a relatively simple solution to this, but it is truly
escaping me. (Yes, I am a relative newbie!) Another example of this type
problem would be finding the most expensive item in an order for a variety
of orders.
Any assistance will be greatly appreciated!
Thanks!
Don