select a.lectno
,(b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100) * 100 apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,(a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100) * 100 mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,(a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100) * 100 fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,(a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100) * 100 spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,(a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100) * 100 dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end <= b.attrate then 1 else 0 end ispassa
,case when case when b.isrebate=1 then d.midcutrfd else d.midcut end <= a.ex0lectpoint then 1 else 0 end ispassm
,case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end <= a.ex1lectpoint then 1 else 0 end ispassf
,case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end <= a.sd0lectpoint then 1 else 0 end ispasss
,case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end <= a.sd1lectpoint then 1 else 0 end ispassd
,case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end <= ifnull(a.at0lectcnt,0) then 1 else 0 end ispassat
,case when
case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end <= ifnull(a.at0lectcnt,0) then 1 else 0 end = 1 and
case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end <= b.attrate then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.midcutrfd else d.midcut end <= a.ex0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end <= a.ex1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end <= a.sd0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end <= a.sd1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.cutrfd else d.cut end <=
((b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100 * 100))
+((a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100)* 100)
+((a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100)* 100)
+((a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100)* 100)
+((a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100)* 100) then 1 else 0 end = 1 then 1 else 0 end ispass
from (
select a.lectno
,sum(ex0cnt) ex0cnt,sum(ex0lectcnt) ex0lectcnt,sum(ex0lectpoint) ex0lectpoint
,sum(ex1cnt) ex1cnt,sum(ex1lectcnt) ex1lectcnt,sum(ex1lectpoint) ex1lectpoint
,sum(sd0cnt) sd0cnt,sum(sd0lectcnt) sd0lectcnt,sum(sd0lectpoint) sd0lectpoint
,sum(sd1cnt) sd1cnt,sum(sd1lectcnt) sd1lectcnt,sum(sd1lectpoint) sd1lectpoint
,sum(rs0cnt) rs0cnt,sum(rs0lectcnt) rs0lectcnt,sum(rs0lectpoint) rs0lectpoint
,sum(at0cnt) at0cnt,sum(at0lectcnt) at0lectcnt
from (
select a.lectno
,count(b.exno) ex0cnt,count(c.lectno) ex0lectcnt,avg(ifnull(c.tpoint,0) / b.tpoint * 100) ex0lectpoint
,0 ex1cnt,0 ex1lectcnt,0 ex1lectpoint
,0 sd0cnt,0 sd0lectcnt,0 sd0lectpoint
,0 sd1cnt,0 sd1lectcnt,0 sd1lectpoint
,0 rs0cnt,0 rs0lectcnt,0 rs0lectpoint
,0 at0cnt,0 at0lectcnt
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
and b.lectno=#lectno#
and b.userno=#userno#
and b.attrate <= #attrateunder#
and b.isrebate=#isrebate#
and b.lectno in ($lectnos$)
inner join users c on c.userno=b.userno and c.status=1
and c.userid=#userid#
and c.username=#username#
where a.ismaster=0
and a.cgno=#cgno#
and a.tmno=#tmno#
and a.cmno=#cmno#
and a.cmno in ($cmnos$)
and a.cshape in ($cshapes$)
and a.isdel=0
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=0 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,count(b.exno),count(c.lectno),avg(ifnull(c.tpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
and b.lectno=#lectno#
and b.userno=#userno#
and b.attrate <= #attrateunder#
and b.isrebate=#isrebate#
and b.lectno in ($lectnos$)
inner join users c on c.userno=b.userno and c.status=1
and c.userid=#userid#
and c.username=#username#
where a.ismaster=0
and a.cgno=#cgno#
and a.tmno=#tmno#
and a.cmno=#cmno#
and a.cmno in ($cmnos$)
and a.cshape in ($cshapes$)
and a.isdel=0
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=1 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
and b.lectno=#lectno#
and b.userno=#userno#
and b.attrate <= #attrateunder#
and b.isrebate=#isrebate#
and b.lectno in ($lectnos$)
inner join users c on c.userno=b.userno and c.status=1
and c.userid=#userid#
and c.username=#username#
where a.ismaster=0
and a.cgno=#cgno#
and a.tmno=#tmno#
and a.cmno=#cmno#
and a.cmno in ($cmnos$)
and a.cshape in ($cshapes$)
and a.isdel=0
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=0 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
and b.lectno=#lectno#
and b.userno=#userno#
and b.attrate <= #attrateunder#
and b.isrebate=#isrebate#
and b.lectno in ($lectnos$)
inner join users c on c.userno=b.userno and c.status=1
and c.userid=#userid#
and c.username=#username#
where a.ismaster=0
and a.cgno=#cgno#
and a.tmno=#tmno#
and a.cmno=#cmno#
and a.cmno in ($cmnos$)
and a.cshape in ($cshapes$)
and a.isdel=0
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=1 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.rsno),count(c.lectno),0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
and b.lectno=#lectno#
and b.userno=#userno#
and b.attrate <= #attrateunder#
and b.isrebate=#isrebate#
and b.lectno in ($lectnos$)
inner join users c on c.userno=b.userno and c.status=1
and c.userid=#userid#
and c.username=#username#
where a.ismaster=0
and a.cgno=#cgno#
and a.tmno=#tmno#
and a.cmno=#cmno#
and a.cmno in ($cmnos$)
and a.cshape in ($cshapes$)
and a.isdel=0
) a
left outer join cmrs b on b.cmno=a.cmno and b.rstype=0 and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.cmino),count(c.lectno)
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
and b.lectno=#lectno#
and b.userno=#userno#
and b.attrate <= #attrateunder#
and b.isrebate=#isrebate#
and b.lectno in ($lectnos$)
inner join users c on c.userno=b.userno and c.status=1
and c.userid=#userid#
and c.username=#username#
where a.ismaster=0
and a.cgno=#cgno#
and a.tmno=#tmno#
and a.cmno=#cmno#
and a.cmno in ($cmnos$)
and a.cshape in ($cshapes$)
and a.isdel=0
) a
left outer join cminning b on b.cmno=a.cmno and b.isonline =0 and b.isscd = 1
left outer join lectinning c on c.cmino=b.cmino and c.lectno = a.lectno and c.istatus = 2
group by a.lectno
) a
group by a.lectno
) a
inner join lect b on b.lectno=a.lectno
inner join cmev d on d.cmno=b.cmno
select a.*
from (
select a.lectno,b.userno,b.payno
,row_number() over(order by $orderby$ c.cname,c.cmno,u.username ) rno
,count(a.lectno) over() pagetotalcount
,b.isrebate
,case when ppl.asname is not null then ppl.asname else ua.asname end asname
,ppl.brno,ppl.ceoname,ppl.post,ppl.address1,ppl.address2,ppl.btype,ppl.bkind,ppl.eino,ppl.mname,ppl.association
,CAST(AES_DECRYPT(UNHEX(ppl.mphone), ) AS char) mphone
,CAST(AES_DECRYPT(UNHEX(ppl.taxemail), ) AS char) taxemail
,u.username,u.userid,u.slevel,u.uduty
,b.iscomplete,b.completetime,b.completeno,b.sdate,b.edate
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno), ) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno), ) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), ) AS char) mobile
,b.cmisno
,p.payoktime,p.payamt
,c.cshape,c.sstime,c.cmno,c.cname,c.classno,c.studytime
,t.tyear
,cg.cgname,cg.pcgno,pcg.cgname as pcgname
,d.isoffabs
,b.attrate
,a.apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,a.mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,a.fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,a.spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,a.dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,a.ispassat
,e.sseq,e.estart,e.eend,e.studyplace
,f.istatus
,cc.cname studyplacename
,tm.cname typemanname, te.cname typeeduname
,tg.cname typegradename, tj.cname typejobname
,date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') edatestring
,pi.tbankuser rbankuser,pi.rbank,pi.pino,pi.rbankamt
,CAST(AES_DECRYPT(UNHEX(pi.rbankaccnum), ) AS char) as rbankaccnum
from (
) a
inner join lect b on b.lectno=a.lectno
inner join pay p on p.payno=b.payno
inner join users u on u.userno=b.userno and u.status=#ustatus#
left outer join assign ua on ua.asno=u.asno
inner join cm c on c.cmno=b.cmno
inner join cm c2 on c2.cmno=c.pcmno
inner join cmev d on d.cmno=c.cmno
left outer join term t on t.tmno = c.tmno
left outer join cg cg on cg.cgno = c.cgno
left outer join cg pcg on pcg.cgno = cg.pcgno
left outer join payitem pi on pi.payno = p.payno
left outer join cminningscd e on e.cmisno = b.cmisno
left outer join lectinning f on f.lectno = b.lectno and f.cmino = e.cmino
left outer join comcode cc on cc.ccode = e.studyplace and cc.isuse=1
left outer join pplog ppl on ppl.pplno = p.pplno
left outer join comcode tm on tm.ccode = ppl.typeman
left outer join comcode te on te.ccode = ppl.typeedu
left outer join comcode tg on tg.ccode = ppl.typegrade
left outer join comcode tj on tj.ccode = ppl.typejob
c.cshape = #cshape#
e.studyplace = #studyplace#
a.ex0lectcnt < a.ex0cnt
a.ex1lectcnt < a.ex1cnt
a.sd0lectcnt < a.sd0cnt
a.sd1lectcnt < a.sd1cnt
a.rs0lectcnt < a.rs0cnt
c2.cname like concat('%',#cname#,'%')
c.cname like concat('%',#cnamestr#,'%')
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno#
((a.sd0cnt > 0 and a.sd0lectcnt > 0))
a.ispassa = #ispassa#
(a.ispassm = #ispassex# and a.ispassf = #ispassex#)
u.username like concat('%',#usernamestr#,'%')
u.userid like concat('%',#useridstr#,'%')
(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%'))
(case when c.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when c.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
ua.asname like concat('%',#asname#,'%')
date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')
) a
order by a.rno
select a.*
from (
select a.lectno,b.userno,b.payno
,row_number() over(order by $orderby$ c.cname,c.cmno,u.username ) rno
,count(a.lectno) over() pagetotalcount
,b.isrebate
,case when ppl.asname is not null then ppl.asname else ua.asname end asname
,ppl.brno,ppl.ceoname,ppl.post,ppl.address1,ppl.address2,ppl.btype,ppl.bkind,ppl.eino,ppl.mname,ppl.association
,CAST(AES_DECRYPT(UNHEX(ppl.mphone), ) AS char) mphone
,CAST(AES_DECRYPT(UNHEX(ppl.taxemail), ) AS char) taxemail
,u.username,u.userid,u.slevel,u.uduty
,b.iscomplete,b.completetime,b.completeno,b.sdate,b.edate
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno), ) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno), ) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), ) AS char) mobile
,b.cmisno
,p.payoktime,p.payamt
,c.cshape,c.sstime,c.cmno,c.cname,c.classno,c.studytime
,t.tyear
,cg.cgname,cg.pcgno,pcg.cgname as pcgname
,d.isoffabs
,b.attrate
,a.apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,a.mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,a.fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,a.spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,a.dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,a.ispassat
,e.sseq,e.estart,e.eend,e.studyplace
,f.istatus
,cc.cname studyplacename
,tm.cname typemanname, te.cname typeeduname
,tg.cname typegradename, tj.cname typejobname
,date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') edatestring
,pi.tbankuser rbankuser,pi.rbank,pi.pino,pi.rbankamt
,CAST(AES_DECRYPT(UNHEX(pi.rbankaccnum), ) AS char) as rbankaccnum
from (
select a.lectno
,(b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100) * 100 apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,(a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100) * 100 mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,(a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100) * 100 fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,(a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100) * 100 spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,(a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100) * 100 dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end <= b.attrate then 1 else 0 end ispassa
,case when case when b.isrebate=1 then d.midcutrfd else d.midcut end <= a.ex0lectpoint then 1 else 0 end ispassm
,case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end <= a.ex1lectpoint then 1 else 0 end ispassf
,case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end <= a.sd0lectpoint then 1 else 0 end ispasss
,case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end <= a.sd1lectpoint then 1 else 0 end ispassd
,case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end <= ifnull(a.at0lectcnt,0) then 1 else 0 end ispassat
,case when
case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end <= ifnull(a.at0lectcnt,0) then 1 else 0 end = 1 and
case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end <= b.attrate then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.midcutrfd else d.midcut end <= a.ex0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end <= a.ex1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end <= a.sd0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end <= a.sd1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.cutrfd else d.cut end <=
((b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100 * 100))
+((a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100)* 100)
+((a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100)* 100)
+((a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100)* 100)
+((a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100)* 100) then 1 else 0 end = 1 then 1 else 0 end ispass
from (
select a.lectno
,sum(ex0cnt) ex0cnt,sum(ex0lectcnt) ex0lectcnt,sum(ex0lectpoint) ex0lectpoint
,sum(ex1cnt) ex1cnt,sum(ex1lectcnt) ex1lectcnt,sum(ex1lectpoint) ex1lectpoint
,sum(sd0cnt) sd0cnt,sum(sd0lectcnt) sd0lectcnt,sum(sd0lectpoint) sd0lectpoint
,sum(sd1cnt) sd1cnt,sum(sd1lectcnt) sd1lectcnt,sum(sd1lectpoint) sd1lectpoint
,sum(rs0cnt) rs0cnt,sum(rs0lectcnt) rs0lectcnt,sum(rs0lectpoint) rs0lectpoint
,sum(at0cnt) at0cnt,sum(at0lectcnt) at0lectcnt
from (
select a.lectno
,count(b.exno) ex0cnt,count(c.lectno) ex0lectcnt,avg(ifnull(c.tpoint,0) / b.tpoint * 100) ex0lectpoint
,0 ex1cnt,0 ex1lectcnt,0 ex1lectpoint
,0 sd0cnt,0 sd0lectcnt,0 sd0lectpoint
,0 sd1cnt,0 sd1lectcnt,0 sd1lectpoint
,0 rs0cnt,0 rs0lectcnt,0 rs0lectpoint
,0 at0cnt,0 at0lectcnt
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
and c.username like concat('%',#usernamestr#,'%')
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=0 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,count(b.exno),count(c.lectno),avg(ifnull(c.tpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
and c.username like concat('%',#usernamestr#,'%')
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=1 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
and c.username like concat('%',#usernamestr#,'%')
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=0 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
and c.username like concat('%',#usernamestr#,'%')
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=1 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.rsno),count(c.lectno),0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
and c.username like concat('%',#usernamestr#,'%')
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmrs b on b.cmno=a.cmno and b.rstype=0 and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.cmino),count(c.lectno)
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
and c.username like concat('%',#usernamestr#,'%')
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cminning b on b.cmno=a.cmno and b.isonline =0 and b.isscd = 1
left outer join lectinning c on c.cmino=b.cmino and c.lectno = a.lectno and c.istatus = 2
group by a.lectno
) a
group by a.lectno
) a
inner join lect b on b.lectno=a.lectno
inner join cmev d on d.cmno=b.cmno
) a
inner join lect b on b.lectno=a.lectno
inner join pay p on p.payno=b.payno
inner join users u on u.userno=b.userno
left outer join assign ua on ua.asno=u.asno
inner join cm c on c.cmno=b.cmno
inner join cm c2 on c2.cmno=c.pcmno
inner join cmev d on d.cmno=c.cmno
left outer join term t on t.tmno = c.tmno
left outer join cg cg on cg.cgno = c.cgno
left outer join cg pcg on pcg.cgno = cg.pcgno
left outer join payitem pi on pi.payno = p.payno
left outer join cminningscd e on e.cmisno = b.cmisno
left outer join lectinning f on f.lectno = b.lectno and f.cmino = e.cmino
left outer join comcode cc on cc.ccode = e.studyplace and cc.isuse=1
left outer join pplog ppl on ppl.pplno = p.pplno
left outer join comcode tm on tm.ccode = ppl.typeman
left outer join comcode te on te.ccode = ppl.typeedu
left outer join comcode tg on tg.ccode = ppl.typegrade
left outer join comcode tj on tj.ccode = ppl.typejob
c.cshape = #cshape#
e.studyplace = #studyplace#
a.ex0lectcnt < a.ex0cnt
a.ex1lectcnt < a.ex1cnt
a.sd0lectcnt < a.sd0cnt
a.sd1lectcnt < a.sd1cnt
a.rs0lectcnt < a.rs0cnt
c2.cname like concat('%',#cname#,'%')
c.cname like concat('%',#cnamestr#,'%')
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno#
((a.sd0cnt > 0 and a.sd0lectcnt > 0))
a.ispassa = #ispassa#
(a.ispassm = #ispassex# and a.ispassf = #ispassex#)
u.username like concat('%',#usernamestr#,'%')
u.userid like concat('%',#useridstr#,'%')
(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%'))
(case when c.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when c.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
ua.asname like concat('%',#asname#,'%')
date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')
) a
order by a.rno
select a.*
from (
select a.lectno,b.userno,b.payno
,row_number() over(order by $orderby$ c.cname,c.cmno,u.username ) rno
,count(a.lectno) over() pagetotalcount
,b.isrebate
,u.username,u.userid,u.slevel,u.uduty
,b.iscomplete,b.completetime,b.completeno,b.sdate,b.edate
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno), ) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno), ) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), ) AS char) mobile
,b.cmisno
,p.payoktime
,c.cshape,c.cmno,c.cname
,d.isoffabs
,b.attrate
,a.apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,a.mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,a.fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,a.spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,a.dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,e.sseq,e.estart,e.eend,e.studyplace
,f.istatus
,cc.cname studyplacename
,date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') edatestring
from (
select a.lectno
,(b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100) * 100 apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,(a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100) * 100 mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,(a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100) * 100 fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,(a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100) * 100 spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,(a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100) * 100 dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
from (
select a.lectno
,sum(ex0cnt) ex0cnt,sum(ex0lectcnt) ex0lectcnt,sum(ex0lectpoint) ex0lectpoint
,sum(ex1cnt) ex1cnt,sum(ex1lectcnt) ex1lectcnt,sum(ex1lectpoint) ex1lectpoint
,sum(sd0cnt) sd0cnt,sum(sd0lectcnt) sd0lectcnt,sum(sd0lectpoint) sd0lectpoint
,sum(sd1cnt) sd1cnt,sum(sd1lectcnt) sd1lectcnt,sum(sd1lectpoint) sd1lectpoint
,sum(rs0cnt) rs0cnt,sum(rs0lectcnt) rs0lectcnt,sum(rs0lectpoint) rs0lectpoint
,sum(at0cnt) at0cnt,sum(at0lectcnt) at0lectcnt
from (
select a.lectno
,count(b.exno) ex0cnt,count(c.lectno) ex0lectcnt,avg(ifnull(c.tpoint,0) / b.tpoint * 100) ex0lectpoint
,0 ex1cnt,0 ex1lectcnt,0 ex1lectpoint
,0 sd0cnt,0 sd0lectcnt,0 sd0lectpoint
,0 sd1cnt,0 sd1lectcnt,0 sd1lectpoint
,0 rs0cnt,0 rs0lectcnt,0 rs0lectpoint
,0 at0cnt,0 at0lectcnt
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=0 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,count(b.exno),count(c.lectno),avg(ifnull(c.tpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=1 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=0 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=1 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.rsno),count(c.lectno),0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmrs b on b.cmno=a.cmno and b.rstype=0 and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.cmino),count(c.lectno)
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cminning b on b.cmno=a.cmno and b.isonline =0 and b.isscd = 1
left outer join lectinning c on c.cmino=b.cmino and c.lectno = a.lectno and c.istatus = 2
group by a.lectno
) a
group by a.lectno
) a
inner join lect b on b.lectno=a.lectno
inner join cmev d on d.cmno=b.cmno
) a
inner join lect b on b.lectno=a.lectno
inner join pay p on p.payno=b.payno
inner join users u on u.userno=b.userno
left outer join assign ua on ua.asno=u.asno
inner join cm c on c.cmno=b.cmno
inner join cm c2 on c2.cmno=c.pcmno
inner join cmev d on d.cmno=c.cmno
left outer join term t on t.tmno = c.tmno
left outer join cminningscd e on e.cmisno = b.cmisno
left outer join lectinning f on f.lectno = b.lectno and f.cmino = e.cmino
left outer join comcode cc on cc.ccode = e.studyplace and cc.isuse=1
left outer join pplog ppl on ppl.pplno = p.pplno
c.cshape = #cshape#
e.studyplace = #studyplace#
a.ex0lectcnt < a.ex0cnt
a.ex1lectcnt < a.ex1cnt
a.sd0lectcnt < a.sd0cnt
a.sd1lectcnt < a.sd1cnt
a.rs0lectcnt < a.rs0cnt
c2.cname like concat('%',#cname#,'%')
c.cname like concat('%',#cnamestr#,'%')
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno#
((a.sd0cnt > 0 and a.sd0lectcnt > 0))
a.ispassa = #ispassa#
(a.ispassm = #ispassex# and a.ispassf = #ispassex#)
u.username like concat('%',#usernamestr#,'%')
u.userid like concat('%',#useridstr#,'%')
(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%'))
(case when c.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when c.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
ua.asname like concat('%',#asname#,'%')
date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')
) a
order by a.rno
select a.*
from (
select a.lectno,b.userno,b.payno
,row_number() over(order by $orderby$ c.cname,c.cmno,u.username ) rno
,count(a.lectno) over() pagetotalcount
,b.isrebate
,case when ppl.asname is not null then ppl.asname else ua.asname end asname
,ppl.brno,ppl.ceoname,ppl.post,ppl.address1,ppl.address2,ppl.btype,ppl.bkind,ppl.eino,ppl.mname,ppl.association
,CAST(AES_DECRYPT(UNHEX(ppl.mphone), ) AS char) mphone
,CAST(AES_DECRYPT(UNHEX(ppl.taxemail), ) AS char) taxemail
,u.username,u.userid,u.slevel,u.uduty
,b.iscomplete,b.completetime,b.completeno,b.sdate,b.edate
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno), ) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno), ) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), ) AS char) mobile
,b.cmisno
,p.payoktime,p.payamt
,c.cshape,c.sstime,c.cmno,c.cname,c.classno,c.studytime
,t.tyear
,cg.cgname,cg.pcgno,pcg.cgname as pcgname
,d.isoffabs
,b.attrate
,a.apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,a.mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,a.fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,a.spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,a.dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,a.ispassat
,e.sseq,e.estart,e.eend,e.studyplace
,f.istatus
,cc.cname studyplacename
,tm.cname typemanname, te.cname typeeduname
,tg.cname typegradename, tj.cname typejobname
,date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') edatestring
,pi.tbankuser rbankuser,pi.rbank,pi.pino,pi.rbankamt
,CAST(AES_DECRYPT(UNHEX(pi.rbankaccnum), ) AS char) as rbankaccnum
from (
select a.lectno
,(b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100) * 100 apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,(a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100) * 100 mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,(a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100) * 100 fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,(a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100) * 100 spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,(a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100) * 100 dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end <= b.attrate then 1 else 0 end ispassa
,case when case when b.isrebate=1 then d.midcutrfd else d.midcut end <= a.ex0lectpoint then 1 else 0 end ispassm
,case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end <= a.ex1lectpoint then 1 else 0 end ispassf
,case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end <= a.sd0lectpoint then 1 else 0 end ispasss
,case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end <= a.sd1lectpoint then 1 else 0 end ispassd
,case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end <= ifnull(a.at0lectcnt,0) then 1 else 0 end ispassat
,case when
case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end <= ifnull(a.at0lectcnt,0) then 1 else 0 end = 1 and
case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end <= b.attrate then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.midcutrfd else d.midcut end <= a.ex0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end <= a.ex1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end <= a.sd0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end <= a.sd1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.cutrfd else d.cut end <=
((b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100 * 100))
+((a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100)* 100)
+((a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100)* 100)
+((a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100)* 100)
+((a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100)* 100) then 1 else 0 end = 1 then 1 else 0 end ispass
from (
select a.lectno
,sum(ex0cnt) ex0cnt,sum(ex0lectcnt) ex0lectcnt,sum(ex0lectpoint) ex0lectpoint
,sum(ex1cnt) ex1cnt,sum(ex1lectcnt) ex1lectcnt,sum(ex1lectpoint) ex1lectpoint
,sum(sd0cnt) sd0cnt,sum(sd0lectcnt) sd0lectcnt,sum(sd0lectpoint) sd0lectpoint
,sum(sd1cnt) sd1cnt,sum(sd1lectcnt) sd1lectcnt,sum(sd1lectpoint) sd1lectpoint
,sum(rs0cnt) rs0cnt,sum(rs0lectcnt) rs0lectcnt,sum(rs0lectpoint) rs0lectpoint
,sum(at0cnt) at0cnt,sum(at0lectcnt) at0lectcnt
from (
select a.lectno
,count(b.exno) ex0cnt,count(c.lectno) ex0lectcnt,avg(ifnull(c.tpoint,0) / b.tpoint * 100) ex0lectpoint
,0 ex1cnt,0 ex1lectcnt,0 ex1lectpoint
,0 sd0cnt,0 sd0lectcnt,0 sd0lectpoint
,0 sd1cnt,0 sd1lectcnt,0 sd1lectpoint
,0 rs0cnt,0 rs0lectcnt,0 rs0lectpoint
,0 at0cnt,0 at0lectcnt
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=0 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,count(b.exno),count(c.lectno),avg(ifnull(c.tpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=1 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=0 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=1 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.rsno),count(c.lectno),0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cmrs b on b.cmno=a.cmno and b.rstype=0 and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.cmino),count(c.lectno)
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
c.username like concat('%',#usernamestr#,'%')
c.userid like concat('%',#useridstr#,'%')
(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%'))
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno# (case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#
(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#
e.studyplace = #studyplace#
and a.cmno = #cmno#
and a2.cname like concat('%',#cname#,'%')
(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
) a
left outer join cminning b on b.cmno=a.cmno and b.isonline =0 and b.isscd = 1
left outer join lectinning c on c.cmino=b.cmino and c.lectno = a.lectno and c.istatus = 2
group by a.lectno
) a
group by a.lectno
) a
inner join lect b on b.lectno=a.lectno
inner join cmev d on d.cmno=b.cmno
) a
inner join lect b on b.lectno=a.lectno
inner join pay p on p.payno=b.payno
inner join users u on u.userno=b.userno
left outer join assign ua on ua.asno=u.asno
inner join cm c on c.cmno=b.cmno
inner join cm c2 on c2.cmno=c.pcmno
inner join cmev d on d.cmno=c.cmno
left outer join term t on t.tmno = c.tmno
left outer join cg cg on cg.cgno = c.cgno
left outer join cg pcg on pcg.cgno = cg.pcgno
left outer join payitem pi on pi.payno = p.payno
left outer join cminningscd e on e.cmisno = b.cmisno
left outer join lectinning f on f.lectno = b.lectno and f.cmino = e.cmino
left outer join comcode cc on cc.ccode = e.studyplace and cc.isuse=1
left outer join pplog ppl on ppl.pplno = p.pplno
left outer join comcode tm on tm.ccode = ppl.typeman
left outer join comcode te on te.ccode = ppl.typeedu
left outer join comcode tg on tg.ccode = ppl.typegrade
left outer join comcode tj on tj.ccode = ppl.typejob
c.cshape = #cshape#
e.studyplace = #studyplace#
a.ex0lectcnt < a.ex0cnt
a.ex1lectcnt < a.ex1cnt
a.sd0lectcnt < a.sd0cnt
a.sd1lectcnt < a.sd1cnt
a.rs0lectcnt < a.rs0cnt
c2.cname like concat('%',#cname#,'%')
c.cname like concat('%',#cnamestr#,'%')
ifnull(b.iscomplete,0)=#iscomplete#
b.cmisno = #cmisno#
((a.sd0cnt > 0 and a.sd0lectcnt > 0))
a.ispassa = #ispassa#
(a.ispassm = #ispassex# and a.ispassf = #ispassex#)
u.username like concat('%',#usernamestr#,'%')
u.userid like concat('%',#useridstr#,'%')
(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%'))
(case when c.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')
(case when c.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')
ua.asname like concat('%',#asname#,'%')
date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#
cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')
) a
order by a.rno
update lect set
,iscomplete=1
where lectno in ($lectnos$)
update lect a
inner join (
) b on b.lectno=a.lectno
set a.udt= ,a.uno=#uno#,a.uip=#uip#
,a.iscomplete=b.ispass
,a.apoint=b.apoint
,a.mpoint=a.mpoint
,a.fpoint=b.fpoint
,a.spoint=b.spoint
,a.dpoint=b.dpoint
,a.tpoint=b.apoint+b.mpoint+b.fpoint+b.spoint+b.dpoint
where a.status=1 and a.ischanged=0
and a.cmno in ($cmnos$)
and a.lectno in ($lectnos$)
select a.cmno, max(a.iscomplete)
from lect a
inner join users b on b.userno=a.userno and b.status=1
where a.cmno in ($cmnos$) and a.status=1 and a.ischanged=0
group by a.cmno
having ifnull(max(a.iscomplete),0) <>1
update lect l
inner join (
select c.lectno,c.completeno,c.completetime
from (
select t1.*
,concat('제 ',t1.cyear,t1.code1,lpad(ifnull(t2.seqNo,0) + t1.rno , 6, 0), ' 호') as completeno
from (
select l.lectno
,date_format(l.edate,'%Y') cyear
,pcg.cgcode code2
,case when cm.cshape = 1 then 'F' else 'N' end code1
,case when te.cremark = '1' then te.refcode
when tm.cremark in ('1','2','3','4') then tm.refcode
else '05' end code3
,case when cm.cshape = 0 then now()
when cm.cshape = 1 then cm.setime
else cs.eend end completetime
,row_number() over(partition by date_format(l.cdt,'%Y') order by l.cdt) rno
from lect l
inner join cm cm on cm.cmno = l.cmno
inner join pay p on p.payno = l.payno
left outer join pplog pl on pl.pplno = p.pplno
inner join cg cg on cg.cgno = cm.cgno
inner join cg pcg on pcg.cgno = cg.pcgno
left outer join comcode tm on tm.isuse=1 and tm.ccode = pl.typeman
left outer join comcode te on te.isuse=1 and te.ccode = pl.typeedu
left outer join cminningscd cs on cs.cmisno = pl.cmisno
where l.lectno in ($lectnos$)
) t1
left outer join (
select date_format(l.edate, '%Y') cyear
,max(substring(replace(replace(l.completeno, ' - N105 - ','N'), '호',''), -6)) seqNo
from lect l
group by date_format(l.edate, '%Y')
) t2 on t2.cyear = t1.cyear
) c
) b
set l.uno = #uno#
,l.udt = now()
,l.uip= #uip#
,l.iscomplete=1
,l.completetime=b.completetime
,l.completeno=b.completeno
where l.lectno = b.lectno
update lect a
inner join (
) b on b.lectno=a.lectno
inner join (
select c.lectno,c.completeno,c.completetime
from (
select t1.*
,concat('제 ',t1.cyear,t1.code1,lpad(ifnull(t2.seqNo,0) + t1.rno , 6, 0), ' 호') as completeno
from (
select l.lectno
,date_format(l.edate,'%Y') cyear
,pcg.cgcode code2
,case when cm.cshape = 1 then 'F' else 'N' end code1
,case when te.cremark = '1' then te.refcode
when tm.cremark in ('1','2','3','4') then tm.refcode
else '05' end code3
,case when cm.cshape = 0 then now()
when cm.cshape = 1 then cm.setime
else cs.eend end completetime
,row_number() over(partition by date_format(l.cdt,'%Y') order by l.cdt) rno
from lect l
inner join cm cm on cm.cmno = l.cmno
inner join pay p on p.payno = l.payno
left outer join pplog pl on pl.pplno = p.pplno
inner join cg cg on cg.cgno = cm.cgno
inner join cg pcg on pcg.cgno = cg.pcgno
left outer join comcode tm on tm.isuse=1 and tm.ccode = pl.typeman
left outer join comcode te on te.isuse=1 and te.ccode = pl.typeedu
left outer join cminningscd cs on cs.cmisno = pl.cmisno
where 1=1
and l.lectno in ($lectnos$)
and l.lectno =#lectno#
) t1
left outer join (
select date_format(l.edate, '%Y') cyear
,max(substring(replace(replace(l.completeno, ' - N105 - ','N'), '호',''), -6)) seqNo
from lect l
group by date_format(l.edate, '%Y')
) t2 on t2.cyear = t1.cyear
) c
) c on c.lectno = a.lectno
inner join cm d on d.cmno = a.cmno
set a.udt= ,a.uno=#uno#,a.uip=#uip#
,a.iscomplete=b.ispass
,a.apoint=b.apoint
,a.mpoint=a.mpoint
,a.fpoint=b.fpoint
,a.spoint=b.spoint
,a.dpoint=b.dpoint
,a.tpoint=b.apoint+b.mpoint+b.fpoint+b.spoint+b.dpoint
,a.completetime = case when b.ispass = 1 then c.completetime else null end
,a.completeno = c.completeno
where a.status=1 and a.ischanged=0 and a.lectno = c.lectno
and a.cmno = #cmno#
and a.lectno = #lectno#
and a.cmno in ($cmnos$)
and a.lectno in ($lectnos$)
update lect
set
,iscomplete=0
,completetime=null
where lectno=#lectno#
select distinct c.lectno , b.cmno
,case when c.iscomplete = 1 then 1 else 0 end iscomplete
from lect a2
inner join cm a on a.cmno = a2.cmno
inner join cm b on b.cmno = a.cmno
inner join lect c on c.cmno = b.cmno
where c.status=1 and c.ischanged=0 and a2.lectno in ($lectnos$)
group by b.cmno,c.lectno
select distinct c.lectno , b.cmno
,case when c.iscomplete = 1 then 1 else 0 end iscomplete
from lect a2
inner join cm a on a.cmno = a2.cmno
inner join cm b on b.cmno = a.cmno
inner join lect c on c.cmno = b.cmno
where c.status=1 and c.ischanged=0 and a2.cmno in ($cmnos$)
group by b.cmno,c.lectno
select a.*
from (
) a
a.lectno = #lectno#