Home » SQL & PL/SQL » SQL & PL/SQL » Please help, using the same field under different conditions
Please help, using the same field under different conditions [message #22198] Sat, 28 September 2002 08:48 Go to next message
Jake
Messages: 14
Registered: August 2000
Junior Member
How do you do this? Take the same field under different conditions?

Create a report that lists the name of each person who has a superior.
Have two columns one for the subordinate’s name and one for their superior’s name. Order by the subordinate’s name.

The first table is the Personnel table which has names and ids. The second table is the Command table which ONLY has command.superiorid and command.subordinateid. These are foreign keys related to the personnel table.
Re: Please help, using the same field under different conditions [message #22203 is a reply to message #22198] Sat, 28 September 2002 18:47 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Double-join to the personnel table:

select p1.name subordinate, p2.name superior
  from command c, personnel p1, personnel p2
 where p1.id = c.subordinateid
   and p2.id = c.superiorid
 order by p1.name;
Previous Topic: Cartesian join on tables with no relationship
Next Topic: Number problem
Goto Forum:
  


Current Time: Sun Apr 28 19:22:43 CDT 2024