elsenorjose
Technical User
I have searched for a way to pivot the results of a query so I can take multiple rows and instead display as a single row with multiple columns but most of the examples I have come across are based on a single table query. I have a query that joins 3 tables and I need to pivot the results.
SELECT
TBL1.LOG_ID
, TBL1.LINE
, TBL2.SURG_NAME
, TBL3.NAME TITLE
FROM TBL1, TBL2, TBL3
WHERE TBL1.SURG_ID = TBL2.PROV_ID(+)
AND TBL1.TITLE_ID = TBL3.TITLE_ID(+)
The results are multiple rows per LOG_ID because there can be multiple surgeons for one surgery (the LOG_ID). What I am trying to do is create a view that will give me results on one row per LOG_ID with the SURG_NAME, and TITLE as multiple columns based on the LINE. So, basically,
LogID Surg1 Title1 Surg2 Title2 Surg3 Title3
There may be more than 3 records retrieved but I have been asked to only retrieve the first 3 LINE numbers, literally 1-3.
Any thoughts using Oracle 10g syntax?
Thank you.
SELECT
TBL1.LOG_ID
, TBL1.LINE
, TBL2.SURG_NAME
, TBL3.NAME TITLE
FROM TBL1, TBL2, TBL3
WHERE TBL1.SURG_ID = TBL2.PROV_ID(+)
AND TBL1.TITLE_ID = TBL3.TITLE_ID(+)
The results are multiple rows per LOG_ID because there can be multiple surgeons for one surgery (the LOG_ID). What I am trying to do is create a view that will give me results on one row per LOG_ID with the SURG_NAME, and TITLE as multiple columns based on the LINE. So, basically,
LogID Surg1 Title1 Surg2 Title2 Surg3 Title3
There may be more than 3 records retrieved but I have been asked to only retrieve the first 3 LINE numbers, literally 1-3.
Any thoughts using Oracle 10g syntax?
Thank you.