,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <includerefid="sql.digest"></include>) AS char) mobile
<isNotNullproperty="ispassex"prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotNullproperty="usernamestr"prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when c.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="asname"prepend="and">ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNullproperty="edate"prepend="and">date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="mobile"prepend="and">cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')</isNotNull>
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <includerefid="sql.digest"></include>) AS char) mobile
<isNotNullproperty="ispassex"prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotNullproperty="usernamestr"prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when c.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="asname"prepend="and">ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNullproperty="edate"prepend="and">date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="mobile"prepend="and">cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')</isNotNull>
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <includerefid="sql.digest"></include>) AS char) mobile
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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="cname">and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) 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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="cname">and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) 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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="ispassex"prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotNullproperty="usernamestr"prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when c.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="asname"prepend="and">ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNullproperty="edate"prepend="and">date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="mobile"prepend="and">cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')</isNotNull>
</dynamic>
) a
<includerefid="sql.pagedynamic"></include>
order by a.rno
</select>
<!-- 성적처리 전체 튜닝 HS - (기존 롤백용 grade.lectgradesToAll_hsbk) -->
<isNotNullproperty="usernamestr"><![CDATA[AND u.username LIKE CONCAT('%', #usernamestr#, '%')]]></isNotNull>
<isNotNullproperty="useridstr"><![CDATA[AND u.userid LIKE CONCAT('%', #useridstr#, '%')]]></isNotNull>
<isNotEmptyproperty="usernameid"><![CDATA[AND (u.userid LIKE CONCAT('%', #usernameid#, '%') OR u.username LIKE CONCAT('%', #usernameid#, '%') OR u.usernameeng LIKE CONCAT('%', #usernameid#, '%'))]]></isNotEmpty>
<isNotNullproperty="asname"><![CDATA[AND ua.asname LIKE CONCAT('%', #asname#, '%')]]></isNotNull>
<isNotNullproperty="mobile"><![CDATA[AND CAST(AES_DECRYPT(UNHEX(u.mobile), 'np123@!') AS CHAR) LIKE CONCAT('%', #mobile#, '%')]]></isNotNull>
<isNotEmptyproperty="edateall"><![CDATA[AND ((a.cshape <> 2 AND b.edate <= DATE_FORMAT(#edateall#, '%Y-%m-%d 23:59:59')) OR (a.cshape = 2 AND e.eend IS NOT NULL AND e.eend <= DATE_FORMAT(#edateall#, '%Y-%m-%d 23:59:59')) OR (a.cshape = 2 AND e.eend IS NULL AND b.edate <= DATE_FORMAT(#edateall#, '%Y-%m-%d 23:59:59')))]]></isNotEmpty>
<isNotNullproperty="edate"><![CDATA[AND DATE_FORMAT((CASE WHEN a.cshape = 2 AND e.eend IS NOT NULL THEN e.eend ELSE b.edate END), '%Y-%m-%d') = #edate#]]></isNotNull>
<isNotNullproperty="edate1"><![CDATA[AND (CASE WHEN a.cshape = 2 AND e.eend IS NOT NULL THEN e.eend ELSE b.edate END) >= #edate1#]]></isNotNull>
<isNotNullproperty="edate2"><![CDATA[AND (CASE WHEN a.cshape = 2 AND e.eend IS NOT NULL THEN e.eend ELSE b.edate END) <= #edate2#]]></isNotNull>
<isNotEmptyproperty="sdateall"><![CDATA[AND (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')]]></isNotEmpty>
</dynamic>
),
aggregated_scores AS (
SELECT
fl.lectno, fl.cmno, fl.isrebate, fl.attrate
, COUNT(DISTINCT CASE WHEN ex.extype = 0 THEN ex.exno END) AS ex0cnt, COUNT(DISTINCT CASE WHEN ex.extype = 0 THEN lex.lectno END) AS ex0lectcnt, AVG(CASE WHEN ex.extype = 0 AND ex.tpoint > 0 THEN IFNULL(lex.tpoint, 0) / ex.tpoint * 100 ELSE 0 END) AS ex0lectpoint
, COUNT(DISTINCT CASE WHEN ex.extype = 1 THEN ex.exno END) AS ex1cnt, COUNT(DISTINCT CASE WHEN ex.extype = 1 THEN lex.lectno END) AS ex1lectcnt, AVG(CASE WHEN ex.extype = 1 AND ex.tpoint > 0 THEN IFNULL(lex.tpoint, 0) / ex.tpoint * 100 ELSE 0 END) AS ex1lectpoint
, COUNT(DISTINCT CASE WHEN sd.sdtype = 0 THEN sd.sdno END) AS sd0cnt, COUNT(DISTINCT CASE WHEN sd.sdtype = 0 THEN lsd.lectno END) AS sd0lectcnt, AVG(CASE WHEN sd.sdtype = 0 AND sd.tpoint > 0 THEN IFNULL(lsd.cpoint, 0) / sd.tpoint * 100 ELSE 0 END) AS sd0lectpoint
, COUNT(DISTINCT CASE WHEN sd.sdtype = 1 THEN sd.sdno END) AS sd1cnt, COUNT(DISTINCT CASE WHEN sd.sdtype = 1 THEN lsd.lectno END) AS sd1lectcnt, AVG(CASE WHEN sd.sdtype = 1 AND sd.tpoint > 0 THEN IFNULL(lsd.cpoint, 0) / sd.tpoint * 100 ELSE 0 END) AS sd1lectpoint
, COUNT(DISTINCT CASE WHEN rs.rstype = 0 THEN rs.rsno END) AS rs0cnt, COUNT(DISTINCT CASE WHEN rs.rstype = 0 THEN lrs.lectno END) AS rs0lectcnt
, COUNT(DISTINCT ci.cmino) AS at0cnt, COUNT(DISTINCT li.lectno) AS at0lectcnt
FROM filtered_lect fl
LEFT JOIN cmex ex ON ex.cmno = fl.cmno AND ex.isdel = 0 LEFT JOIN lectex lex ON lex.lectno = fl.lectno AND lex.exno = ex.exno
LEFT JOIN cmsd sd ON sd.cmno = fl.cmno AND sd.isdel = 0 LEFT JOIN lectsd lsd ON lsd.lectno = fl.lectno AND lsd.sdno = sd.sdno
LEFT JOIN cmrs rs ON rs.cmno = fl.cmno AND rs.rstype = 0 AND rs.isdel = 0 LEFT JOIN lectrs lrs ON lrs.lectno = fl.lectno AND lrs.rsno = rs.rsno
LEFT JOIN cminning ci ON ci.cmno = fl.cmno AND ci.isonline = 0 AND ci.isscd = 1 LEFT JOIN lectinning li ON li.cmino = ci.cmino AND li.lectno = fl.lectno AND li.istatus = 2
GROUP BY fl.lectno, fl.cmno, fl.isrebate, fl.attrate
UNION ALL
SELECT
fl.lectno, fl.cmno, fl.isrebate, fl.attrate
, COUNT(DISTINCT CASE WHEN ex.extype = 0 THEN ex.exno END) AS ex0cnt, COUNT(DISTINCT CASE WHEN ex.extype = 0 THEN lex.lectno END) AS ex0lectcnt, AVG(CASE WHEN ex.extype = 0 AND ex.tpoint > 0 THEN IFNULL(lex.tpoint, 0) / ex.tpoint * 100 ELSE 0 END) AS ex0lectpoint
, COUNT(DISTINCT CASE WHEN ex.extype = 1 THEN ex.exno END) AS ex1cnt, COUNT(DISTINCT CASE WHEN ex.extype = 1 THEN lex.lectno END) AS ex1lectcnt, AVG(CASE WHEN ex.extype = 1 AND ex.tpoint > 0 THEN IFNULL(lex.tpoint, 0) / ex.tpoint * 100 ELSE 0 END) AS ex1lectpoint
, COUNT(DISTINCT CASE WHEN sd.sdtype = 0 THEN sd.sdno END) AS sd0cnt, COUNT(DISTINCT CASE WHEN sd.sdtype = 0 THEN lsd.lectno END) AS sd0lectcnt, AVG(CASE WHEN sd.sdtype = 0 AND sd.tpoint > 0 THEN IFNULL(lsd.cpoint, 0) / sd.tpoint * 100 ELSE 0 END) AS sd0lectpoint
, COUNT(DISTINCT CASE WHEN sd.sdtype = 1 THEN sd.sdno END) AS sd1cnt, COUNT(DISTINCT CASE WHEN sd.sdtype = 1 THEN lsd.lectno END) AS sd1lectcnt, AVG(CASE WHEN sd.sdtype = 1 AND sd.tpoint > 0 THEN IFNULL(lsd.cpoint, 0) / sd.tpoint * 100 ELSE 0 END) AS sd1lectpoint
, COUNT(DISTINCT CASE WHEN rs.rstype = 0 THEN rs.rsno END) AS rs0cnt, COUNT(DISTINCT CASE WHEN rs.rstype = 0 THEN lrs.lectno END) AS rs0lectcnt
, COUNT(DISTINCT ci.cmino) AS at0cnt, COUNT(DISTINCT li.lectno) AS at0lectcnt
FROM filtered_lect fl
LEFT JOIN cmex ex ON ex.cmno = fl.cmno AND ex.isdel = 0 LEFT JOIN lectex lex ON lex.lectno = fl.lectno AND lex.exno = ex.exno
LEFT JOIN cmsd sd ON sd.cmno = fl.cmno AND sd.isdel = 0 LEFT JOIN lectsd lsd ON lsd.lectno = fl.lectno AND lsd.sdno = sd.sdno
LEFT JOIN cmrs rs ON rs.cmno = fl.cmno AND rs.rstype = 0 AND rs.isdel = 0 LEFT JOIN lectrs lrs ON lrs.lectno = fl.lectno AND lrs.rsno = rs.rsno
LEFT JOIN cminning ci ON ci.cmno = fl.cmno AND ci.isonline = 0 AND ci.isscd = 1 LEFT JOIN lectinning li ON li.cmino = ci.cmino AND li.lectno = fl.lectno AND li.istatus = 2
, CONCAT(SUBSTRING(CAST(AES_DECRYPT(UNHEX(u.userpno), <includerefid="sql.digest"/>) AS CHAR),1,6),'-',SUBSTRING(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"/>) AS CHAR),7,7)) userpno
, CAST(AES_DECRYPT(UNHEX(u.mobile), <includerefid="sql.digest"/>) AS CHAR) mobile
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <includerefid="sql.digest"></include>) AS char) mobile
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 <isEqualproperty="LeaveUserView"compareValue="N">AND c.status < 99</isEqual>
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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="edate1"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNullproperty="edate2"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#</isNotNull>
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 <isEqualproperty="LeaveUserView"compareValue="N">AND c.status < 99</isEqual><!--and c.status < 99-->
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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="edate1"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNullproperty="edate2"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#</isNotNull>
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 <isEqualproperty="LeaveUserView"compareValue="N">AND c.status < 99</isEqual>
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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="edate1"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNullproperty="edate2"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#</isNotNull>
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 <isEqualproperty="LeaveUserView"compareValue="N">AND c.status < 99</isEqual>
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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="edate1"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNullproperty="edate2"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#</isNotNull>
<isNotNullproperty="cname">and (a2.cname like concat('%',#cname#,'%') or a.cname like concat('%',#cname#,'%'))</isNotNull>
<isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) 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 <isEqualproperty="LeaveUserView"compareValue="N">AND c.status < 99</isEqual>
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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="edate1"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNullproperty="edate2"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#</isNotNull>
<isNotNullproperty="cname">and (a2.cname like concat('%',#cname#,'%') or a.cname like concat('%',#cname#,'%'))</isNotNull>
<isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) 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 <isEqualproperty="LeaveUserView"compareValue="N">AND c.status < 99</isEqual>
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
<isNotNullproperty="usernamestr"prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNullproperty="cmisno"prepend="and">b.cmisno = #cmisno#</isNotNull><isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="edate1"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNullproperty="edate2"prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) <= #edate2#</isNotNull>
<isNotNullproperty="ispassex"prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotNullproperty="usernamestr"prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmptyproperty="sdateall"prepend="and">(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')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when c.cshape = 2 then e.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="asname"prepend="and">ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNullproperty="edate"prepend="and">date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="mobile"prepend="and">cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')</isNotNull>
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) AS CHAR) mobile
LEFT OUTER JOIN cminningscd cis ON l.cmisno = cis.cmisno
INNER JOIN users u ON l.userno = u.userno
INNER JOIN pay p ON p.payno = l.payno
<!--최종평가-->
LEFT OUTER JOIN cmex ce ON l.cmno = ce.cmno AND ce.extype = 1 AND ce.isdel = 0
LEFT OUTER JOIN lectex le ON l.lectno = le.lectno AND ce.exno = le.exno
<!--중간평가-->
LEFT OUTER JOIN cmex ce2 ON l.cmno = ce2.cmno AND ce2.extype = 0 AND ce2.isdel = 0
LEFT OUTER JOIN lectex le2 ON l.lectno = le2.lectno AND ce2.exno = le2.exno
<!--과제-->
LEFT OUTER JOIN cmsd cs ON l.cmno = cs.cmno AND cs.sdtype = 0 AND cs.isdel = 0
LEFT OUTER JOIN lectsd ls ON l.lectno = ls.lectno AND cs.sdno = ls.sdno
<!--토론-->
LEFT OUTER JOIN cmsd cs2 ON l.cmno = cs2.cmno AND cs2.sdtype = 1 AND cs2.isdel = 0
LEFT OUTER JOIN lectsd ls2 ON l.lectno = ls2.lectno AND cs2.sdno = ls2.sdno
<!--설문-->
LEFT OUTER JOIN cmrs cr ON l.cmno = cr.cmno AND cr.rstype = 0 AND cr.isdel = 0
LEFT OUTER JOIN lectrs lt ON l.lectno = lt.lectno AND cr.rsno = lt.rsno
<!--집합출석-->
LEFT OUTER JOIN cminning ci ON l.cmno=ci.cmno AND ci.isonline =0 AND ci.isscd = 1
LEFT OUTER JOIN lectinning li ON ci.cmino = li.cmino AND l.lectno = li.lectno AND li.istatus = 2
WHERE u.status = 1 AND c.ismaster=0 AND c.isdel=0 AND l.status = 1 AND l.ischanged = 0
<isNotNullproperty="usernamestr"prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmptyproperty="sdateall"prepend="and">(case when c.cshape = 0 and l.isrebate = 0 then p.payoktime else l.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when c.cshape = 2 then cis.eend else l.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="edate1"prepend="and">(case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end) >= #edate1#</isNotNull>
<isNotNullproperty="edate2"prepend="and">(case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end) <= #edate2#</isNotNull>
<isNotNullproperty="ispassex"prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotNullproperty="usernamestr"prepend="and">a.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">a.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(a.userid like concat('%',#usernameid#,'%') or a.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmptyproperty="sdateall"prepend="and">(case when a.cshape = 0 and a.isrebate = 0 then a.payoktime else a.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then a.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="asname"prepend="and">a.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and a.eend is not null then a.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="mobile"prepend="and">a.mobile like concat('%',#mobile#,'%')</isNotNull>
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<includerefid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) AS CHAR) mobile
,l.attrate, ifnull(l.mpoint,0) AS mpoint, ifnull(l.fpoint,0) fpoint
,ifnull(l.spoint,0) AS spoint,ifnull(l.dpoint,0) AS dpoint
, ifnull(l.exmpoint,-1) as dblv1, ifnull(l.exfpoint,-1) as dblv2
, ifnull(l.subjectpoint,-1) as dblv3, ifnull(l.discusspoint,-1) as dblv4
LEFT OUTER JOIN cminningscd cis ON l.cmisno = cis.cmisno
INNER JOIN users u ON l.userno = u.userno
INNER JOIN pay p ON p.payno = l.payno
<!--중간평가-->
LEFT OUTER JOIN cmex ce ON l.cmno = ce.cmno AND ce.extype = 0 AND ce.isdel = 0
<!--최종평가-->
LEFT OUTER JOIN cmex ce2 ON l.cmno = ce2.cmno AND ce2.extype = 1 AND ce2.isdel = 0
<!--과제-->
LEFT OUTER JOIN cmsd cs ON l.cmno = cs.cmno AND cs.sdtype = 0 AND cs.isdel = 0
<!--토론-->
LEFT OUTER JOIN cmsd cs2 ON l.cmno = cs2.cmno AND cs2.sdtype = 1 AND cs2.isdel = 0
<!--설문-->
LEFT OUTER JOIN cmrs cr ON l.cmno = cr.cmno AND cr.rstype = 0 AND cr.isdel = 0
LEFT OUTER JOIN lectrs lt ON l.lectno = lt.lectno AND cr.rsno = lt.rsno
<!--집합출석-->
LEFT OUTER JOIN cminning ci ON l.cmno=ci.cmno AND ci.isonline =0 AND ci.isscd = 1
LEFT OUTER JOIN lectinning li ON ci.cmino = li.cmino AND l.lectno = li.lectno AND li.istatus = 2
WHERE u.status < 99 AND c.ismaster=0 AND c.isdel=0 AND l.status = 1 AND l.ischanged = 0
<isNotNullproperty="usernamestr"prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotNullproperty="usernamestr"prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNullproperty="useridstr"prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmptyproperty="usernameid"prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmptyproperty="sdateall"prepend="and">(case when c.cshape = 0 and l.isrebate = 0 then p.payoktime else l.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when c.cshape = 2 then cis.eend else l.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="edate"prepend="and">date_format((case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="edate1"prepend="and">(case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end) >= #edate1#</isNotNull>
<isNotNullproperty="edate2"prepend="and">(case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end) <= #edate2#</isNotNull>
<isNotNullproperty="ispassex"prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotEmptyproperty="sdateall"prepend="and">(case when a.cshape = 0 and a.isrebate = 0 then a.payoktime else a.sdate end) >= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmptyproperty="edateall"prepend="and">(case when a.cshape = 2 then a.eend else b.edate end) <= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNullproperty="asname"prepend="and">a.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNullproperty="edate"prepend="and">date_format((case when a.cshape = 2 and a.eend is not null then a.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNullproperty="mobile"prepend="and">a.mobile like concat('%',#mobile#,'%')</isNotNull>
,(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