Solution for Cut & Divide Text by ',' without Declare or Create Procedure

    xiaoxiao2021-12-14  22

    with Core as  

    (select co.course_number, 

    (case  

    when termid=((substr('¶m1',1,4))-'1990') *100 

    then substr('¶m1',1,9) 

    when termid=((substr('¶m1',1,4))-'1990')*100+1 

    then 'S1' 

    when termid=((substr('¶m1',1,4))-'1990')*100+2 

    then 'S2' 

    when termid=((substr('¶m1',1,4))-'1990')*100+3 

    then 'Q1' 

    when termid=((substr('¶m1',1,4))-'1990')*100+4 

    then 'Q2' 

    when termid=((substr('¶m1',1,4))-'1990')*100+5 

    then 'Q3' 

    when termid=((substr('¶m1',1,4))-'1990')*100+6 

    then 'Q4' 

    end)  

    as Term, 

    co.course_name,cc.section_number,cc.teacherid,cc.studentid from 

    cc  join courses co 

    on co.course_number=cc.course_number 

    and termid>=UPPER( 

    (select ((substr('¶m1',1,4))-'1990')*100 from dual)) 

    group by co.course_number, co.course_name,cc.section_number,cc.teacherid,cc.studentid, 

    (case  

    when termid=((substr('¶m1',1,4))-'1990') *100 

    then substr('¶m1',1,9) 

    when termid=((substr(¶m1',1,4))-'1990')*100+1 

    then 'S1' 

    when termid=((substr('¶m1',1,4))-'1990')*100+2 

    then 'S2' 

    when termid=((substr('¶m1',1,4))-'1990')*100+3 

    then 'Q1' 

    when termid=((substr('¶m1',1,4))-'1990')*100+4 

    then 'Q2' 

    when termid=((substr('¶m1',1,4))-'1990')*100+5 

    then 'Q3' 

    when termid=((substr('¶m1',1,4))-'1990')*100+6 

    then 'Q4' 

    end) 

    order by course_number,section_number) 

    SELECT COURSE_NUMBER,TERM,COURSE_NAME,SECTION_NUMBER,TEACHERNAME,STUDENT_NUMBER,StudentName,HOME_ROOM,FATHERPHONE,FATHEREMAIL,MOTHERPHONE,MOTHEREMAIL FROM 

    ( 

    select course_number,Term,course_name,section_number,t.lastfirst as TeacherName,student_number,s.lastfirst as StudentName,s.home_room,MF.CUST_FATHERMOBILEPHONE AS FATHERPHONE,MF.CUST_FATHEREMAIL AS FATHEREMAIL,MF.CUST_MOTHERMOBILEPHONE AS MOTHERPHONE,MF.CUST_MOTHEREMAIL AS MOTHEREMAIL 

    from students s 

    join core c 

    on s.id=c.studentid 

    and s.enroll_status='0' 

    join teachers t 

    on t.id=c.teacherid 

    join U_STUDENTSUSERFIELDS MF 

    on MF.studentsdcid=s.dcid 

    ) 

    WHERE  

    course_NUMBER=UPPER('¶m2') 

    and 

    ( 

    (case  

    when   

    '¶m3' is null  

    and 1=1 

    then 1 end )=1 

    or  

    (case  

    when  '¶m3' is not null  

    and 

    ( 

    section_number in ( 

      select substr(regexp_substr(UPPER('¶m3'), 

                                '[^,]+', 

                                1, 

                                level), 

                  1 

                  ,40) 

      from dual 

      connect by level <= regexp_count(UPPER('¶m3'), 

                                       ',') + 1) 

    ) 

    then 1 end)=1 

    ) 

    order by course_number,section_number,studentname,student_number 

    ; 

    转载请注明原文地址: https://ju.6miu.com/read-962883.html

    最新回复(0)