Tim85
asked on
SQL: how to sequence parent records by child rankings
I am looking for some help in creating a simple SQL query to retrieve records from two related tables.
The tables (in simplified form) are as follows:
CREATE TABLE parent (
primary_key integer,
name varchar(20),
PRIMARY KEY (primary_key)
);
CREATE TABLE child (
primary_key integer,
parent_key integer,
name varchar(20),
age integer,
PRIMARY KEY (primary_key)
);
I need to select records from the parent table that have at least one child, ordered by the age of the oldest child.
It seems a simple enough challenge but I have been unable to crack it. I hope somebody can help.
Many thanks,
Tim
The tables (in simplified form) are as follows:
CREATE TABLE parent (
primary_key integer,
name varchar(20),
PRIMARY KEY (primary_key)
);
CREATE TABLE child (
primary_key integer,
parent_key integer,
name varchar(20),
age integer,
PRIMARY KEY (primary_key)
);
I need to select records from the parent table that have at least one child, ordered by the age of the oldest child.
It seems a simple enough challenge but I have been unable to crack it. I hope somebody can help.
Many thanks,
Tim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER