Oracle中wm_concat()的使用方法
阿新 • • 發佈:2019-01-30
以下兩種方式使用wm_concat()的使用方法是等效的。
方法一:使用視窗函式,wm_concat支援視窗函式
select distinct classKey,className, classOrder, weekDayKey, lessonkey, lessonName, lessonType, wm_concat(subjectkey) over(partition by classKey,className, classOrder, weekDaykey, lessonkey, lessonName,lessonType), wm_concat(subjectName) over(partition by classKey,className, classOrder, weekDaykey, lessonkey, lessonName,lessonType) from VW_CLASSCourseTable Where schoolKey = P_SchoolKey And gradeKey = P_GradeKey And termKey = P_TermKey order by classOrder asc, weekDaykey asc, lessonType asc
方法二:使用group by方式
select classKey,className, classOrder, weekDaykey, lessonkey, lessonName, lessonType, wm_concat(subjectkey), wm_concat(subjectName) from VW_CLASSCourseTable Where schoolKey = P_SchoolKey And gradeKey = P_GradeKey And termKey = P_TermKey group by classKey,className, classOrder, weekDaykey, lessonkey, lessonName,lessonType order by classOrder asc, weekDaykey asc, lessonType asc ;