2017-12-13 14 views
0

私の最初のSELECT文の結果を結合する手助けが必要である。その結果は、2つの選択ステートメント

SELECT cRefNum, cName, cProgram || '-' || cCode || '-' || cSection as CourseDesc, cTimeStart, cTimeEnd, cDay, ct.cCampus, cBuildingSection || cRoom AS Room, cSchedType 
from coursedetails cd inner join coursetimes ct 
using (cRefNum) 
where cRefNum = 3816; 

query 1 result

私の第2の選択ステートメントは、次のとおりです。

select cRefNum, LISTAGG(fname|| ' ' || lname, ', ') within group (order by cRefNum) as Teachers 
from teachers 
where cRefNum = 3816 
group by cRefNum; 

結果は

query 2 result

私は何を達成しようとしていることである:

enter image description here

答えて

0
select a.cRefNum, cName, CourseDesc, cTimeStart, cTimeEnd, cDay, Campus, Room, cSchedType, Teachers 
from 
(select cRefNum, cName, cProgram || '-' || cCode || '-' || cSection as CourseDesc, cTimeStart, cTimeEnd, cDay, ct.cCampus as Campus, cBuildingSection || cRoom AS Room, cSchedType from coursedetails cd inner join coursetimes ct using (cRefNum) where cRefNum = 3816) a, 
(select cRefNum, LISTAGG(fname|| ' ' || lname, ', ') within group (order by cRefNum) as Teachers from teachers where cRefNum = 3816 group by cRefNum) b 
where a.cRefNum = b.cRefNum; 

これはそれを修正し、本当に長いですし、私はそれを短くするのに十分なのか分かりません。

関連する問題