Using Oracle 10g, I have a "Persons" table and a "Tasks" table, as shown below:
PERSONS Table
=============== ==
PID, FName, LName
-------------------------------
1, John, Smith
2, Bob, Johnson
3, Jane, Walters
TASKS Table
=============== ==
PID, Task#, Task
-------------------------------
1, 1, Change tires
1, 2, Cut grass
1, 3, Watch TV
2, 1, Mop floors
2, 2, Eat sandwich
3, 1, Divide and conquer
The tables are related through the PID field, and each person can have from 0 to 4 tasks assigned to them.
What I need is a query that for any Task # n (where n is 1 to 4), it will return the person's name and Task (or a null value if no Task # n is assigned for that person). For example, if I wanted to see the information for Task # 2, the query should return:
FName, LName, Task
-------------------------------
John, Smith, Cut grass
Bob, Johnsson, Eat sandwich
Jane, Walters, (null)
Any help is greatly appreciated
PERSONS Table
=============== ==
PID, FName, LName
-------------------------------
1, John, Smith
2, Bob, Johnson
3, Jane, Walters
TASKS Table
=============== ==
PID, Task#, Task
-------------------------------
1, 1, Change tires
1, 2, Cut grass
1, 3, Watch TV
2, 1, Mop floors
2, 2, Eat sandwich
3, 1, Divide and conquer
The tables are related through the PID field, and each person can have from 0 to 4 tasks assigned to them.
What I need is a query that for any Task # n (where n is 1 to 4), it will return the person's name and Task (or a null value if no Task # n is assigned for that person). For example, if I wanted to see the information for Task # 2, the query should return:
FName, LName, Task
-------------------------------
John, Smith, Cut grass
Bob, Johnsson, Eat sandwich
Jane, Walters, (null)
Any help is greatly appreciated
Comment