i got a question this is what i have
SQL> desc trktripleg
Name Null? Type
----------------------------------------- -------- ----------------------------
T# NOT NULL NUMBER(10)
LEG# NOT NULL NUMBER(2)
DEPARTURE NOT NULL VARCHAR2(30)
DESTINATION NOT NULL VARCHAR2(30)
I tried do the following
SQL> select destination,departure from trktripleg where T#=15;
DESTINATION DEPARTURE
------------------------------ ------------------------------
Adelaide Melbourne
Melbourne Sydney
How do i make it this way…
SOURCE DESTINATION DESTINATION2
Adelaide Melbourne Sydney
Assume if there only 1 destination
SQL> select destination,departure from trktripleg where T#=11;
DESTINATION DEPARTURE
------------------------------ ------------------------------
Sydney Melbourne
SOURCE DESTINATION DESTINATION2
Adelaide Melbourne
I am doing view now as like i provide the T# , it will display the source destination depature
Some raw insert data..
INSERT INTO TRKTRIPLEG VALUES(11, 1, 'Melbourne', 'Sydney');
INSERT INTO TRKTRIPLEG VALUES(15, 1, 'Sydney', 'Melbourne');
INSERT INTO TRKTRIPLEG VALUES(15, 2, 'Melbourne', 'Adelaide');
Thanks for all help. I am using oracle sql.
If I understood your schema correctly you can do this
SQL FIDDLE EXAMPLE