Solution for Cut & Divide Text by ',' without Declare or Create Procedure
2016-12-02 12:53
239 查看
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
;
(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
;
相关文章推荐
- Solution for calculate & Output without Declare (Useful for SQL Developer)
- Solution for error "Store update, insert, or delete statement affected an unexpected number of rows"
- ERROR 1074 (42000): Column length too big for column 'Flist' (max = 21845); use BLOB or TEXT instead
- 解决Cannot proceed without .vf or "physical" font for PDF output
- DevExpress Exception Solution - The target "X" for the callback could not be found or did not implement ICallbackEventHandler
- How to create columns like "bigint" or "longtext" in Rails migrations
- Solution For "could not be located or a different control is assigned to the same ID after postback"
- Create a DLL by CSharp or VB.Net for VBA--摘自网络
- 使用TOMCAT5.5连接池连接mysql(解决Cannot create JDBC driver of class '' for connect URL 'null')
- Solution for supporting fieldLength when creating shapefile by Geotools
- dynamic create option element for select by javascript
- ActionScript 3.0 Step By Step系列(三):学学流程控制,编编if-else & switch & while & for
- Cannot create JDBC driver of class '' for connect URL 'null' 解决方案
- Cannot create JDBC driver of class '' for connect URL 'null' 错误
- Solution for Can’t update table ‘t1′ in stored function/trigger because it is already used by statement which invoked this store
- ArcGIS Engine中初始化许可常见问题归纳,the application is not licensed to create or modify schema for this type of data
- How To Create 32-bit Import Libraries Without .OBJs or Source
- Solution Manager Key (SMSY) (Solution Manager 4.0) Step by Step Procedure with Screens
- Nathan A. Good, «Regular Expression Recipes for Windows Developers: A Problem-Solution Approach»
- Word Hacks: Tips & Tools for Taming Your Text