我的第一个选择陈述是:
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;
结果是:
我的第二个选择陈述是:
select cRefNum, LISTAGG(fname|| ' ' || lname, ', ') within group (order by cRefNum) as Teachers
from teachers
where cRefNum = 3816
group by cRefNum;
结果是:
我想要实现的目标是:
答案 0 :(得分: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;
这解决了这个问题,但确实很长,而且我不知道缩短它。