insert into menuauth (usertype,authname,menuno,isdel, )
select max(usertype)+1,#authname#,1,0,
from menuauth
update menuauth
set authname=#authname#
where usertype=#usertype#
delete a
from menuauth a
left outer join(
select count(userno) usercnt,usertype
from users
where usertype = #usertype#
group by usertype
)b on b.usertype = a.usertype
where a.usertype = #usertype# and (b.usercnt < 1 or b.usercnt is null);
insert into menuauth (usertype,authname,menuno,isdel,cdt,cno,udt,uno,uip)
select *
from (
select #usertype# usertype,#authname# authname,1 menuno,0 isdel,now() cdt,#uno# cno,now() udt,#uno# uno,#uip# uip
) a
where not exists(
select usertype,authname,menuno
from menuauth
where usertype = #usertype# and menuno = 1
);
update menuauth a
left outer join (
select count(userno) usercnt,usertype
from users
where usertype = #usertype# and status=1
group by usertype
) b on b.usertype = a.usertype
set isdel=1
where a.usertype=#usertype# and (b.usercnt < 1 or b.usercnt is null);
select a.ccode, a.cname, a.cgroup, a.isuse, a.corder, a.cgroupname, a.refcode, a.cremark, a.ccode value, a.cname text, a.refcode value2,a.cdt,a.udt
from comcode a
a.ccode=#ccode#
a.ccode in ($ccodes$)
a.cgroup=#cgroup#
a.cgroup in ($cgroups$)
a.refcode=#refcode#
a.isuse=#isuse#
a.cname like concat('%', #cnamelike#,'%')
a.isuse=1
order by $orderby$
order by a.cgroupname, a.corder
select cgroup, cgroup value, cgroupname, cgroupname text, count(cgroup) ccount
from comcode
isuse=#isuse#
group by cgroup, cgroupname
order by $orderby$
select a.*
from (
select a.ntno,a.tcode,a.tname,a.ntype
,a.ntno value,concat(a.tname,'(',a.tcode,')') text
,a.tcode acode,a.ntno ncsno,a.tname ncsname
,row_number() over(order by $orderby$ a.tname ) rno
,count(a.cdt) over() pagetotalcount
from ncst a
a.tname like concat('%',#ncsname#, '%')
a.ntype=#ntype#
) a
order by a.rno
select a.*
from (
select a.nmno,a.mcode,a.mname,a.acode
,a.nmno ncsno,a.mname ncsname
,t.ntno,t.tname
,row_number() over(order by $orderby$ a.mname ) rno
,count(a.cdt) over() pagetotalcount
from ncsm a
inner join ncst t on t.ntno=a.ntno
a.mname like concat('%',#ncsname#, '%')
) a
order by a.rno
select a.*
from (
select a.nbno,a.bcode,a.bname,a.acode
,a.nbno ncsno,a.bname ncsname
,m.nmno,m.mname
,t.ntno,t.tname
,row_number() over(order by $orderby$ a.bname ) rno
,count(a.cdt) over() pagetotalcount
from ncsb a
inner join ncsm m on m.nmno=a.nmno
inner join ncst t on t.ntno=m.ntno
a.bname like concat('%',#ncsname#, '%')
) a
order by a.rno
select a.*
from (
select a.ndno,a.dname,a.acode
,a.ndno ncsno,a.dname ncsname,a.dcode
,b.nbno,b.bname,b.bcode
,m.nmno,m.mname,m.mcode
,t.ntno,t.tname,t.tcode
,row_number() over(order by $orderby$ a.dname ) rno
,count(a.cdt) over() pagetotalcount
from ncsd a
inner join ncsb b on b.nbno=a.nbno
inner join ncsm m on m.nmno=b.nmno
inner join ncst t on t.ntno=m.ntno
a.dname like concat('%',#ncsname#, '%')
) a
order by a.rno
select a.fileno,a.fgno,a.orgname,a.fileurl,a.filesize,a.extension,a.dcount,a.cdt
from fileinfo a
where a.isdel=0
and a.FGNo=#fgno#
and a.FGNo in ($fgnos$)
INSERT INTO filegroup (tablename,columnname, ) VALUES (#tablename#, #columnname#, )
SELECT LAST_INSERT_ID()
INSERT INTO fileinfo (fgno, orgname, fileurl, filesize, extension, dcount, isdel, )
values
(#fgno#, #Files[].orgname#, #Files[].fileurl#, #Files[].filesize#, #Files[].extension#, 0, 0, ,#uno#, ,#uno#,#uip#)
update fileinfo set dcount = dcount + 1 where fileno=#fileno#
select a.fileno,a.fgno,a.orgname,a.fileurl,a.filesize,a.extension,a.dcount,a.cno,a.uno
,b.tablename,b.columnname
from fileinfo a
inner join filegroup b on b.fgno=a.fgno
where a.FileNo = #fileno# and a.isdel = 0
select a.fileno,a.fgno,a.orgname,a.fileurl,a.filesize,a.extension,a.dcount,a.cno,a.uno
,b.tablename,b.columnname
from fileinfo a
inner join filegroup b on b.fgno=a.fgno
where a.FileNo = #fileno#
update fileinfo set uip=#uip#, uno=#uno#, isdel=1 where fileno=#fileno# and (#isadmin# = 1 or #uno# = -999 or cno=#uno#)
update fileinfo set uip=#uip#, uno=#uno#, isdel=1 where fgno=#fgno# and (#isadmin# = 1 or #uno# = -999 or cno=#uno#)
insert into fileinfo (fgno,orgname,fileurl,filesize,extension,dcount,isdel, )
select #nfgno#,a.orgname,concat(substr(a.fileurl,1,instr(a.fileurl,'.')-1),'_$copytype$_',#uno#,'_',#nfgno#, substr(a.fileurl,instr(a.fileurl,'.'))),filesize,extension,dcount,isdel,
from fileinfo a
where a.fgno=#ofgno# and a.isdel=0
select g.ntno,f.nmno,d.nbno,c.ndno,b.nuno
from ncst g
left outer join ncsm f on f.ntno=g.ntno
left outer join ncsb d on d.nmno=f.nmno
left outer join ncsd c on c.nbno=d.nbno
left outer join ncsu b on b.ndno=c.nbno
g.ntno=#ncst#
f.nmno=#ncsm#
d.nbno=#ncsb#
c.ndno=#ncsd#
group by c.ndno,d.nbno,f.nmno,g.ntno
select 4 ndepth,a.*
from (
select a.nuno,a.ucode,a.uname
,b.ndno,b.dcode,b.dname,b.acode dacode
,c.nbno,c.bcode,c.bname,c.acode bacode
,d.nmno,d.mcode,d.mname,d.acode macode
,e.ntno,e.tcode,e.tname,e.ntype
,row_number() over(order by $orderby$ a.ucode ) rno
,count(a.cdt) over() pagetotalcount
from ncsu a
inner join ncsd b on b.ndno=a.ndno
inner join ncsb c on c.nbno=b.nbno
inner join ncsm d on d.nmno=c.nmno
inner join ncst e on e.ntno=d.ntno
(a.ucode = #codename# or a.uname like concat('%',#codename#,'%'))
) a
order by a.rno
select 3 ndepth,a.*
from (
select b.ndno,b.dcode,b.dname,b.acode dacode
,c.nbno,c.bcode,c.bname,c.acode bacode
,d.nmno,d.mcode,d.mname,d.acode macode
,e.ntno,e.tcode,e.tname,e.ntype
,row_number() over(order by $orderby$ b.dcode ) rno
,count(b.cdt) over() pagetotalcount
from ncsd b
inner join ncsb c on c.nbno=b.nbno
inner join ncsm d on d.nmno=c.nmno
inner join ncst e on e.ntno=d.ntno
(b.dcode = #codename# or b.dname like concat('%',#codename#,'%'))
) a
order by a.rno
select 2 ndepth,a.*
from (
select c.nbno,c.bcode,c.bname,c.acode bacode
,d.nmno,d.mcode,d.mname,d.acode macode
,e.ntno,e.tcode,e.tname,e.ntype
,row_number() over(order by $orderby$ c.bcode ) rno
,count(c.cdt) over() pagetotalcount
from ncsb c
inner join ncsm d on d.nmno=c.nmno
inner join ncst e on e.ntno=d.ntno
(c.bcode = #codename# or c.bname like concat('%',#codename#,'%'))
) a
order by a.rno
select 1 ndepth,a.*
from (
select d.nmno,d.mcode,d.mname,d.acode macode
,e.ntno,e.tcode,e.tname,e.ntype
,row_number() over(order by $orderby$ d.mcode ) rno
,count(d.cdt) over() pagetotalcount
from ncsm d
inner join ncst e on e.ntno=d.ntno
(d.mcode = #codename# or d.mname like concat('%',#codename#,'%'))
) a
order by a.rno
select 0 ndepth,a.*
from (
select e.ntno,e.tcode,e.tname,e.ntype
,row_number() over(order by $orderby$ e.tcode ) rno
,count(e.cdt) over() pagetotalcount
from ncst e
(e.tcode = #codename# or e.tname like concat('%',#codename#,'%'))
) a
order by a.rno
select count(b.ntno)
from (select 1 col1) a
left outer join ncst b
b.ntno<>#notno#
b.ntype=#ntype#
b.tcode=#ncscode#
select count(b.n$ndepthname$no)
from (select 1 col1) a
left outer join ncs$ndepthname$ b
b.n$ndepthname$no<>#notno#
b.n$pndepthname$no=#pno#
b.$ndepthname$code=#ncscode#
select tcode from ncst where ntno=#pno#
select concat(b.tcode,a.mcode)
from ncsm a
inner join ncst b on b.ntno=a.ntno
where a.nmno=#pno#
select concat(c.tcode,b.mcode,a.bcode)
from ncsb a
inner join ncsm b on b.nmno=a.nmno
inner join ncst c on c.ntno=b.ntno
where a.nbno=#pno#
insert into ncst (ntype,tcode,tname, )
values (#ntype#,#ncscode#,#ncsname#, )
update ncst set
,tcode=#ncscode#,tname=#ncsname#
where ntno=#ncsno#
insert into ncs$ndepthname$ (n$pndepthname$no,$ndepthname$code,$ndepthname$name,acode, )
values (#pno#,#ncscode#,#ncsname#,#acode#, )
update ncs$ndepthname$ set
,$ndepthname$code=#ncscode#,$ndepthname$name=#ncsname#,acode=#acode#
where n$ndepthname$no=#ncsno#
delete from ncs$ndepthname$ where n$ndepthname$no=#ncsno#
delete from ncsu where nuno in ($nunos$);
delete from ncsd where ndno in ($nunos$);
delete from ncsb where nbno in ($nunos$);
delete from ncsm where nmno in ($nunos$);
delete from ncs$ndepthname$ where n$ndepthname$no=#ncsno#;
select n$ndepthname$no,$ndepthname$name,acode
,n$ndepthname$no value,$ndepthname$name text
,$ndepthname$code ncscode
from ncs$ndepthname$ where n$pndepthname$no=#pno#
select distinct(a.cmno),b.ndno cmndno,c.ndno ncsdno,d.nbno,f.nmno,g.ntno
from cm a
inner join cmncsd b on b.cmno=a.cmno
inner join ncsd c on c.ndno=b.ndno
left outer join ncsb d on d.nbno=c.nbno
left outer join ncsm f on f.nmno=d.nmno
left outer join ncst g on g.ntno=f.ntno
where a.isdel=0 and a.isrefund=1
and g.ntno=#ncst#
and f.nmno=#ncsm#
and d.nbno=#ncsb#
and c.ndno=#ncsd#
group by a.cmno,b.ndno,c.ndno,d.nbno,f.nmno,g.ntno
select ntno ncsno,tname ncsname,tcode ncscode,ntype pno,#ndepth# ndepth
,ntno value
,tname text
from ncs$ndepthname$
where n$ndepthname$no=#ncsno#
select n$ndepthname$no ncsno,$ndepthname$name ncsname,$ndepthname$code ncscode,n$pndepthname$no pno,#ndepth# ndepth
,n$ndepthname$no value
,$ndepthname$name text
from ncs$ndepthname$
where n$ndepthname$no=#ncsno#
select 3 ndepth,v.ndno ncsno,v.dname ncsname,v.dcode ncscode,case when v.ndno=u.ndno then 1 else 0 end isact
from ncsu u
inner join ncsd d on d.ndno=u.ndno
inner join ncsd v on v.nbno=d.nbno
where u.nuno=#ncsno#
union all
select 2 ndepth,v.nbno ncsno,v.bname ncsname,v.bcode ncscode,case when v.nbno=b.nbno then 1 else 0 end isact
from ncsu u
inner join ncsd d on d.ndno=u.ndno
inner join ncsb b on b.nbno=d.nbno
inner join ncsb v on v.nmno=b.nmno
where u.nuno=#ncsno#
union all
select 1 ndepth,v.nmno ncsno,v.mname ncsname,v.mcode ncscode,case when v.nmno=m.nmno then 1 else 0 end isact
from ncsu u
inner join ncsd d on d.ndno=u.ndno
inner join ncsb b on b.nbno=d.nbno
inner join ncsm m on m.nmno=b.nmno
inner join ncsm v on v.ntno=m.ntno
where u.nuno=#ncsno#
union all
select 0 ndepth,v.ntno ncsno,v.tname ncsname,v.tcode ncscode,case when v.ntno=t.ntno then 1 else 0 end isact
from ncsu u
inner join ncsd d on d.ndno=u.ndno
inner join ncsb b on b.nbno=d.nbno
inner join ncsm m on m.nmno=b.nmno
inner join ncst t on t.ntno=m.ntno
inner join ncst v on v.ntype=t.ntype
where u.nuno=#ncsno#
order by ndepth,ncscode
select 2 ndepth,v.nbno ncsno,v.bname ncsname,v.bcode ncscode,case when v.nbno=b.nbno then 1 else 0 end isact
from ncsd d
inner join ncsb b on b.nbno=d.nbno
inner join ncsb v on v.nmno=b.nmno
where d.ndno=#ncsno#
union all
select 1 ndepth,v.nmno ncsno,v.mname ncsname,v.mcode ncscode,case when v.nmno=m.nmno then 1 else 0 end isact
from ncsd d
inner join ncsb b on b.nbno=d.nbno
inner join ncsm m on m.nmno=b.nmno
inner join ncsm v on v.ntno=m.ntno
where d.ndno=#ncsno#
union all
select 0 ndepth,v.ntno ncsno,v.tname ncsname,v.tcode ncscode,case when v.ntno=t.ntno then 1 else 0 end isact
from ncsd d
inner join ncsb b on b.nbno=d.nbno
inner join ncsm m on m.nmno=b.nmno
inner join ncst t on t.ntno=m.ntno
inner join ncst v on v.ntype=t.ntype
where d.ndno=#ncsno#
order by ndepth,ncscode
select 1 ndepth,v.nmno ncsno,v.mname ncsname,v.mcode ncscode,case when v.nmno=m.nmno then 1 else 0 end isact
from ncsb b
inner join ncsm m on m.nmno=b.nmno
inner join ncsm v on v.ntno=m.ntno
where b.nbno=#ncsno#
union all
select 0 ndepth,v.ntno ncsno,v.tname ncsname,v.tcode ncscode,case when v.ntno=t.ntno then 1 else 0 end isact
from ncsb b
inner join ncsm m on m.nmno=b.nmno
inner join ncst t on t.ntno=m.ntno
inner join ncst v on v.ntype=t.ntype
where b.nbno=#ncsno#
order by ndepth,ncscode
select 0 ndepth,v.ntno ncsno,v.tname ncsname,v.tcode ncscode,case when v.ntno=t.ntno then 1 else 0 end isact
from ncsm m
inner join ncst t on t.ntno=m.ntno
inner join ncst v on v.ntype=t.ntype
where m.nmno=#ncsno#
order by ndepth,ncscode
select d.ndno,d.acode dacode,d.dname
from ncsd d
inner join ncsb b on b.nbno=d.nbno
inner join ncsm m on m.nmno=b.nmno
inner join ncst t on t.ntno=m.ntno and t.ntype=#ntype#
where d.acode in ($dacodes$)
select u.ndno,u.ucode
from ncsu u
where u.ndno=#ndno# and u.ucode in ($ucodes$)
insert into ncsu (ndno,ucode,acode,uname, )
values $inquery$
select a.dtype,count(distinct b.intval) intval,sum(b.intval2) intval2
from (
select 1 dtype union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6 union all
select 7 union all
select 8 union all
select 9 union all
select 10 union all
select 11 union all
select 12) a
left outer join (
select month(a.cdt) dtype,a.userno intval,count(a.logno) intval2
from loginlog a
a.logsite=#logsite#
a.loginstatus=#loginstatus#
a.loginstatus < #loginstatuslt#
year(a.cdt) = #year#
group by month(a.cdt),a.userno
) b on b.dtype=a.dtype
group by a.dtype
order by a.dtype,b.intval
select a.*
from (
select b.username strval,b.userid strval2,a.cdt time,a.uip strval3,a.loginstatus intval
,row_number() over(order by $orderby$ a.cdt desc,b.username,b.userno ) rno
,count(a.cdt) over() pagetotalcount
from loginlog a
left outer join users b on b.userno=a.userno
a.cdt between #start# and #end#
b.userid=#userid#
) a
order by a.rno
select a.*
from (
select b.username strval,b.userid strval2,a.cdt time,a.uip strval3,ifnull(c.menuname, ifnull(d.pagename, a.loginfo)) strval4
,row_number() over(order by $orderby$ a.cdt desc,b.username,b.userno ) rno
,count(a.cdt) over() pagetotalcount
from pagelog a
left outer join users b on b.userno=a.userno
left outer join menu c on a.logsite=0 and c.menuno=a.menuno
left outer join menupage d on a.logsite=1 and d.pno=a.pno
a.cdt between #start# and #end#
b.userid=#userid#
) a
order by a.rno
select a.*
from (
select a.logtype,a.logtarget,a.userno,a.logdata,a.cdt,a.uip
,b.userid cnoid,b.username cnoname
,case a.logtarget when 21 then c.userid else null end userid
,case a.logtarget when 21 then c.username when 31 then d.asname when 32 then e.mname else null end username
,row_number() over(order by $orderby$ a.cdt desc,b.username,b.userno ) rno
,count(a.cdt) over() pagetotalcount
from actlog a
inner join users b on b.userno=a.cno
left outer join users c on a.logtarget=21 and c.userno=a.userno
left outer join assign d on a.logtarget=31 and d.asno=a.userno
left outer join assignman e on a.logtarget=32 and e.asmno=a.userno
a.cdt between #start# and #end#
c.userid=#userid#
c.username=#username#
b.userid=#cnouid#
b.username=#cnoname#
) a
order by a.rno
insert into actlog (logtype,logtarget,userno,logdata, )
values(#logtype#,#logtarget#,#userno#,#logdata#, )
insert into authlog(logtype,userno,usertypeorg,usertypenew, )
values(#logtype#,#userno#,#usertypeorg#,#usertypenew#, )
insert into authlog(logtype,userno,usertypeorg,usertypenew, )
select #logtype#,#userno#,a.usertype,#usertypenew#,
from users a
where a.userno=#userno# and a.usertype <> #usertypenew#
select a.*
from (
select a.logtype,a.userno,a.usertypeorg,a.usertypenew,a.cdt,a.uip
,case when a.usertypeorg = 1 then '교육생' when d1.authname is null then '-' else d1.authname end usertypeorgstr
,case when a.usertypenew = 1 then '교육생' when d2.authname is null then '-' else d2.authname end usertypenewstr
,b.userid cnoid,b.username cnoname
,c.userid,c.username
,row_number() over(order by $orderby$ a.cdt desc ) rno
,count(a.cdt) over() pagetotalcount
from authlog a
inner join users b on b.userno=a.cno
left outer join users c on a.logtype > 0 and c.userno=a.userno
left outer join (
select distinct usertype,authname
from menuauth
) d1 on d1.usertype=a.usertypeorg
left outer join (
select distinct usertype,authname
from menuauth
) d2 on d2.usertype = a.usertypenew
a.cdt between #start# and #end#
c.userid=#userid#
) a
order by a.rno
select case b.ptype when 2 then 2 when 3 then 1 else 0 end dtype, 0 intval, case b.ptype when 2 then '교재' when 3 then '시험' else '강좌' end strval,'매출' strval2
,sum(case when month(a.payoktime)=1 then b.payamt else 0 end) longval
,sum(case when month(a.payoktime)=2 then b.payamt else 0 end) longval2
,sum(case when month(a.payoktime)=3 then b.payamt else 0 end) longval3
,sum(case when month(a.payoktime)=4 then b.payamt else 0 end) longval4
,sum(case when month(a.payoktime)=5 then b.payamt else 0 end) longval5
,sum(case when month(a.payoktime)=6 then b.payamt else 0 end) longval6
,sum(case when month(a.payoktime)=7 then b.payamt else 0 end) longval7
,sum(case when month(a.payoktime)=8 then b.payamt else 0 end) longval8
,sum(case when month(a.payoktime)=9 then b.payamt else 0 end) longval9
,sum(case when month(a.payoktime)=10 then b.payamt else 0 end) longval10
,sum(case when month(a.payoktime)=11 then b.payamt else 0 end) longval11
,sum(case when month(a.payoktime)=12 then b.payamt else 0 end) longval12
from pay a
inner join payitem b on b.payno=a.payno and a.pstatus=1
where year(a.payoktime)=#year# and a.pstatus=1
group by b.ptype,month(a.payoktime)
union all
select case b.ptype when 2 then 2 when 3 then 1 else 0 end dtype, 1 intval, '','환불' strval
,(case when month(b.refundtime)=1 then b.refundamt else 0 end) * -1 longval
,(case when month(b.refundtime)=2 then b.refundamt else 0 end) * -1 longval2
,(case when month(b.refundtime)=3 then b.refundamt else 0 end) * -1 longval3
,(case when month(b.refundtime)=4 then b.refundamt else 0 end) * -1 longval4
,(case when month(b.refundtime)=5 then b.refundamt else 0 end) * -1 longval5
,(case when month(b.refundtime)=6 then b.refundamt else 0 end) * -1 longval6
,(case when month(b.refundtime)=7 then b.refundamt else 0 end) * -1 longval7
,(case when month(b.refundtime)=8 then b.refundamt else 0 end) * -1 longval8
,(case when month(b.refundtime)=9 then b.refundamt else 0 end) * -1 longval9
,(case when month(b.refundtime)=10 then b.refundamt else 0 end) * -1 longval10
,(case when month(b.refundtime)=11 then b.refundamt else 0 end) * -1 longval11
,(case when month(b.refundtime)=12 then b.refundamt else 0 end) * -1 longval12
from pay a
inner join payitem b on b.payno=a.payno and a.pstatus=1 and b.rstatus > 0 and b.refundtime is not null and year(b.refundtime)=#year#
where a.pstatus=1 and a.rstatus > 0
group by b.ptype,month(b.refundtime)
order by dtype,intval
select g.cgno intval,g.cgname strval,f.cgno intval2,f.cgname strval2,e.cname strval3,sum(b.payamt) longval,count(b.pino) intval3,sum(b.refundamt) longval2
,sum(case when b.rstatus=0 then 0 else 1 end) intval4,sum(b.payamt)-sum(b.refundamt) longval3
from term a
inner join payitem b on b.ptype < 2 and b.pstatus=1
inner join pay c on c.payno=b.payno and c.pstatus=1
inner join cm d on d.cmno=b.itemno and d.tmno = a.tmno
inner join cm e on e.cmno=d.pcmno
inner join cg f on f.cgno=e.cgno
inner join cg g on g.cgno=f.pcgno
a.tyear=#year#
a.tmno=#tmno#
group by g.cgno,g.cgname,f.cgno,f.cgname
order by g.cgname,g.cgno,f.cgname,f.cgno,e.cname,e.cmno
select
b.cshape, case when b.cshape=0 then '온라인' when b.cshape=1 then '오프라인' else '혼합' end cshapename
,b3.cgno,b2.cgno,f.cmno
,b3.cgname strval,b2.cgname strval2,f.cname strval3
,count(c.lectno) intval,sum(c.iscomplete) intval2
,sum(e.isjoin) intval3,sum(case when e.isjoin=1 and c.iscomplete=1 then 1 else 0 end) intval4
,sum(case when e.isjoin=0 then 1 else 0 end) intval5,sum(case when e.isjoin=0 and c.iscomplete=1 then 1 else 0 end) intval6
,sum(case when c.isrebate=0 then 1 else 0 end) intval7,sum(case when c.isrebate=0 and c.iscomplete=1 then 1 else 0 end) intval8
,sum(case when c.isrebate=1 then 1 else 0 end) intval9,sum(case when c.isrebate=1 and c.iscomplete=1 then 1 else 0 end) intval10
from term a
inner join cm b on b.tmno=a.tmno
inner join lect c on c.cmno=b.cmno and c.status=1
inner join users d on d.userno=c.userno
left outer join assign e on e.asno=d.asno
inner join cm f on f.cmno=b.pcmno
inner join cg b2 on b2.cgno=f.cgno
inner join cg b3 on b3.cgno=b2.pcgno
a.tyear=#year#
a.tmno=#tmno#
b.cshape=#cshape#
b3.cgno=#pcgno#
b2.cgno=#cgno#
group by b3.cgno,b2.cgno,f.cmno,b3.cgname,b2.cgname,f.cname
order by b3.cgname,b3.cgno,b2.cgname,b2.cgno,f.cname,f.cmno
select
b.cshape, case when b.cshape=0 then '온라인' when b.cshape=1 then '오프라인' else '혼합' end cshapename
,b3.cgno,b2.cgno,f.cmno,b.cmno
,b3.cgname strval,b2.cgname strval2,f.cname strval3,concat(b.cname,'(',b.classno,')') strval4,concat(date_format(b.sstime,'%y.%m.%d'),'~',date_format(b.setime,'%y.%m.%d')) strval5
,count(c.lectno) intval
,sum(c.iscomplete) intval2
,sum(case when (c.iscomplete <> 1 or c.iscomplete is null) then 1 else 0 end) intval15
,sum(e.isjoin) intval3
,sum(case when e.isjoin=1 and c.iscomplete=1 then 1 else 0 end) intval4
,sum(case when e.isjoin=0 then 1 else 0 end) intval5
,sum(case when e.isjoin=0 and c.iscomplete=1 then 1 else 0 end) intval6
,sum(case when c.isrebate=0 then 1 else 0 end) intval7
,sum(case when c.isrebate=0 and c.iscomplete=1 then 1 else 0 end) intval8
,sum(case when c.isrebate=1 then 1 else 0 end) intval9
,sum(case when c.isrebate=1 and c.iscomplete=1 then 1 else 0 end) intval10
,sum(case when c.isrebate=0 and (c.iscomplete <> 1 or c.iscomplete is null) then 1 else 0 end) intval13
,sum(case when c.isrebate=1 and (c.iscomplete <> 1 or c.iscomplete is null) then 1 else 0 end) intval14
,sum(case when plog.isaccommodation = 1 then 1 else 0 end) intval16
,sum(case when plog.isaccommodation = 1 and c.iscomplete=1 then 1 else 0 end) intval17
,sum(case when plog.isaccommodation = 1 and (c.iscomplete <> 1 or c.iscomplete is null) then 1 else 0 end) intval18
,sum(case when (plog.isaccommodation <> 1 or plog.isaccommodation is null) then 1 else 0 end) intval19
,sum(case when (plog.isaccommodation <> 1 or plog.isaccommodation is null) and c.iscomplete=1 then 1 else 0 end) intval20
,sum(case when (plog.isaccommodation <> 1 or plog.isaccommodation is null) and (c.iscomplete <> 1 or c.iscomplete is null) then 1 else 0 end) intval21
from term a
inner join cm b on b.tmno=a.tmno
inner join lect c on c.cmno=b.cmno and c.status=1
inner join users d on d.userno=c.userno
left outer join assign e on e.asno=d.asno
inner join cm f on f.cmno=b.pcmno
inner join cg b2 on b2.cgno=f.cgno
inner join cg b3 on b3.cgno=b2.pcgno
inner join pay p on c.payno = p.payno
inner join pplog plog on p.pplno = plog.pplno
a.tyear=#year#
a.tmno=#tmno#
b.cshape=#cshape#
b3.cgno=#pcgno#
b2.cgno=#cgno#
group by b3.cgno,b2.cgno,f.cmno,b3.cgname,b2.cgname,f.cname,b.cmno,b.cname,b.sstime,b.setime
order by b3.cgname,b3.cgno,b2.cgname,b2.cgno,f.cname,f.cmno,b.cname,b.cmno,b.classno
select b3.cgno,b2.cgno,f.cmno
,b3.cgname strval,b2.cgname strval2,f.cname strval3
,count(c.lectno) intval,sum(c.iscomplete) intval2
$columns$
,sum(case when e.asctg is null then 1 else 0 end) intvaletc,sum(case when e.asctg is null and c.iscomplete=1 then 1 else 0 end) intvaletc2
from term a
inner join cm b on b.tmno=a.tmno
inner join lect c on c.cmno=b.cmno and c.status=1
inner join users d on d.userno=c.userno
left outer join assign e on e.asno=d.asno
inner join cm f on f.cmno=b.pcmno
inner join cg b2 on b2.cgno=f.cgno
inner join cg b3 on b3.cgno=b2.pcgno
a.tyear=#year#
a.tmno=#tmno#
group by b3.cgno,b2.cgno,f.cmno,b3.cgname,b2.cgname,f.cname
order by b3.cgname,b3.cgno,b2.cgname,b2.cgno,f.cname,f.cmno
select b3.cgno,b2.cgno,f.cmno
,b3.cgname strval,b2.cgname strval2,f.cname strval3
,count(c.lectno) intval,sum(c.iscomplete) intval2
$columns$
,sum(case when d.ccposition is null then 1 else 0 end) intvaletc,sum(case when d.ccposition is null and c.iscomplete=1 then 1 else 0 end) intvaletc2
from term a
inner join cm b on b.tmno=a.tmno
inner join lect c on c.cmno=b.cmno and c.status=1
inner join users d on d.userno=c.userno
inner join cm f on f.cmno=b.pcmno
inner join cg b2 on b2.cgno=f.cgno
inner join cg b3 on b3.cgno=b2.pcgno
a.tyear=#year#
a.tmno=#tmno#
group by b3.cgno,b2.cgno,f.cmno,b3.cgname,b2.cgname,f.cname
order by b3.cgname,b3.cgno,b2.cgname,b2.cgno,f.cname,f.cmno
select a.tyear,a.tseq,b3.cgno pcgno,b3.cgname pcgname,b2.cgno,b2.cgname,f.cname pcname,b.cname,b.classno,b.sstime,b.setime,b.infee,b.outfee,e.asname,e.isjoin,e2.cname asctgname,c.isrebate
,d.username,d.userid,c.cdt,d2.cname ccpositionname,c.iscomplete
from term a
inner join cm b on b.tmno=a.tmno
inner join lect c on c.cmno=b.cmno and c.status=1
inner join users d on d.userno=c.userno
left outer join comcode d2 on d2.ccode=d.ccposition
left outer join assign e on e.asno=d.asno
left outer join comcode e2 on e2.ccode=.e.asctg
inner join cm f on f.cmno=b.pcmno
inner join cg b2 on b2.cgno=f.cgno
inner join cg b3 on b3.cgno=b2.pcgno
a.tyear=#year#
a.tmno=#tmno#
order by b3.cgname,b3.cgno,b2.cgname,b2.cgno,f.cname,f.cmno,b.cname,b.cmno,b.classno
select a.*
from (
select row_number() over(order by b3.cgname,b3.cgno,b2.cgname,b2.cgno,f.cname,f.cmno,b.cname,b.cmno,b.classno,d.username,d.userno) rno, count(c.lectno) over() pagerowcount
,a.tyear,a.tseq,b3.cgno pcgno,b3.cgname pcgname,b2.cgno,b2.cgname,f.cname pcname,b.cname,b.classno,b.sstime,b.setime,b.infee,b.outfee,e.asname,e.isjoin,e2.cname asctgname,c.isrebate
,d.username,d.userid,d.depart
,CAST(AES_DECRYPT(UNHEX(d.mobile), ) AS char) mobile
,CAST(AES_DECRYPT(UNHEX(d.email), ) AS char) email
,c.attrate,c.cdt,c.iscomplete
,c2.payamt
,d2.cname ccpositionname
,count(a.cdt) over() pagetotalcount
from term a
inner join cm b on b.tmno=a.tmno and b.pcmno=#pcmno# and b.cmno=#cmno#
inner join lect c on c.cmno=b.cmno and c.status=1
left outer join payitem c2 on c2.pino=c.pino
inner join users d on d.userno=c.userno and d.username like concat('%',#username#,'%') and d.asno=#asno#
left outer join comcode d2 on d2.ccode=d.ccposition
left outer join assign e on e.asno=d.asno
left outer join comcode e2 on e2.ccode=.e.asctg
inner join cm f on f.cmno=b.pcmno
inner join cg b2 on b2.cgno=f.cgno
inner join cg b3 on b3.cgno=b2.pcgno
where ifnull(c2.refundstatus,0)=0
and a.tyear=#year#
and a.tmno=#tmno#
and e.asname like concat('%',#asname#,'%')
) a
order by a.rno
select a.rno,a.pcgno,a.pcgname,a.cgno,a.cgname,a.pcname,a.cmno,a.cname,a.classno,a.sstime,a.setime
,a.studyplace
,a.infee,a.outfee
,a.infeetotal
,a.outfeetotal
,a.feeloc,a.feebkpr,a.feebrt,a.feemat,a.feefoo,a.feeetc,a.prtcnt
,a.studyplacename
,a.incount
,a.outcount
,a.totcount
,a.pfee
,a.managers
,group_concat(c.username order by case when b.userno is null then 1 else 0 end,b.week,b.iseq separator $profsep$) profnames
,concat(substr(min(b.ist),1,2),':',substr(min(b.ist),3,2),'~',substr(max(b.iet),1,2),':',substr(max(b.iet),3,2)) itime
from (
select a.rno,a.pcgno,a.pcgname,a.cgno,a.cgname,a.pcname,a.cmno,a.cname,a.classno,a.sstime,a.setime
,a.studyplace
,a.infee,a.outfee
,a.infeetotal
,a.outfeetotal
,a.feeloc,a.feebkpr,a.feebrt,a.feemat,a.feefoo,a.feeetc,a.prtcnt
,a.studyplacename
,a.incount
,a.outcount
,a.totcount
,sum(b.pfee) pfee
,group_concat(case when b2.usertype=11 then null else b2.username end separator $profsep$) managers
from (
select row_number() over(order by b.sstime) rno
,b3.cgno pcgno,b3.cgname pcgname,b2.cgno,b2.cgname,f.cname pcname,b.cmno,b.cname,b.classno,b.sstime,b.setime
,b.studyplace
,b.infee,b.outfee
,b.infee*sum(case when e.isjoin=1 then 1 else 0 end) infeetotal
,b.outfee*sum(case when e.isjoin=1 then 0 else 1 end) outfeetotal
,cmc.feeloc,cmc.feebkpr,cmc.feebrt,cmc.feemat,cmc.feefoo,cmc.feeetc,cmc.prtcnt
,cc.cname studyplacename
,sum(case when e.isjoin=1 then 1 else 0 end) incount
,sum(case when e.isjoin=1 then 0 else 1 end) outcount
,count(c.lectno) totcount
from term a
inner join cm b on b.tmno=a.tmno and b.cshape=1
left outer join cmcalc cmc on cmc.cmno=b.cmno
inner join lect c on c.cmno=b.cmno and c.status=1
inner join users d on d.userno=c.userno
left outer join assign e on e.asno=d.asno
inner join cm f on f.cmno=b.pcmno
inner join cg b2 on b2.cgno=f.cgno
inner join cg b3 on b3.cgno=b2.pcgno
left outer join comcode cc on cc.ccode=b.studyplace
where a.tyear=#year#
group by b3.cgname,b3.cgno,b2.cgname,b2.cgno,f.cname,f.cmno,b.cname,b.cmno,b.classno
,b.sstime,b.setime
,b.studyplace
,cmc.infee, b.infee,cmc.outfee,b.outfee
,cmc.feeloc,cmc.feebkpr,cmc.feebrt,cmc.feemat,cmc.feefoo,cmc.feeetc,cmc.prtcnt
,cc.cname
) a
inner join cmprof b on b.cmno=a.cmno
inner join users b2 on b2.userno=b.userno
group by a.rno,a.pcgno,a.pcgname,a.cgno,a.cgname,a.pcname,a.cmno,a.cname,a.classno,a.sstime,a.setime
,a.studyplace
,a.infee,a.outfee
,a.infeetotal
,a.outfeetotal
,a.feeloc,a.feebkpr,a.feebrt,a.feemat,a.feefoo,a.feeetc,a.prtcnt
,a.studyplacename
,a.incount
,a.outcount
,a.totcount
) a
inner join cminning b on b.cmno=a.cmno
left outer join users c on c.userno=b.userno
group by a.rno,a.pcgno,a.pcgname,a.cgno,a.cgname,a.pcname,a.cmno,a.cname,a.classno,a.sstime,a.setime
,a.studyplace
,a.infee,a.outfee
,a.infeetotal
,a.outfeetotal
,a.feeloc,a.feebkpr,a.feebrt,a.feemat,a.feefoo,a.feeetc,a.prtcnt
,a.studyplacename
,a.incount
,a.outcount
,a.totcount
,a.pfee
,a.managers
order by a.rno
update cmcalc a
inner join (
select #Ds[].cmno# cmno,#Ds[].infee# infee,#Ds[].outfee# outfee,#Ds[].feeloc# feeloc,#Ds[].feebkpr# feebkpr,#Ds[].feebrt# feebrt,#Ds[].feemat# feemat,#Ds[].feefoo# feefoo,#Ds[].feeetc# feeetc,#Ds[].prtcnt# prtcnt
) b on b.cmno=a.cmno
set a.feeloc =b.feeloc
,a.feebkpr =b.feebkpr
,a.feebrt =b.feebrt
,a.feemat =b.feemat
,a.feefoo =b.feefoo
,a.feeetc =b.feeetc
,a.prtcnt =b.prtcnt;
insert into cmcalc (cmno,infee,outfee,feeloc,feebkpr,feebrt,feemat,feefoo,feeetc,prtcnt, )
select a.cmno,a.infee,a.outfee,a.feeloc,a.feebkpr,a.feebrt,a.feemat,a.feefoo,a.feeetc,a.prtcnt,
from (
select #Ds[].cmno# cmno,#Ds[].infee# infee,#Ds[].outfee# outfee,#Ds[].feeloc# feeloc,#Ds[].feebkpr# feebkpr,#Ds[].feebrt# feebrt,#Ds[].feemat# feemat,#Ds[].feefoo# feefoo,#Ds[].feeetc# feeetc,#Ds[].prtcnt# prtcnt
) a
left outer join cmcalc b on b.cmno=a.cmno
where b.cmno is null
select a.cmno,a.feeloc,a.feebkpr,a.feebrt,a.feemat,a.feefoo,a.feeetc,a.prtcnt
,b.cname,b.classno,b.sstime,b.setime
,c.pfee
,d.username,CAST(AES_DECRYPT(UNHEX(d.userpno), ) AS char) userpno,d.bankname,CAST(AES_DECRYPT(UNHEX(d.bankno), ) AS char) bankno,d.post,d.address1,d.address2
,row_number() over(order by d.username) rno
from cmcalc a
inner join cm b on b.cmno=a.cmno
inner join cmprof c on c.cmno=b.cmno
inner join users d on d.userno=c.userno
where a.cmno=#cmno#
order by rno
select count(b.daokey)
from (select 1 col1) a
left outer join npsystem b on b.daokey=#daokey#
select sum(intval) intval,sum(intval2) intval2
from (
select 0 intval, count(m.nmno) intval2
from ncst t
left outer join ncsm m on m.ntno=t.ntno
where t.ntno=#ncsno#
union all
select 0 intval,count(b.nbno) intval2
from ncst t
left outer join ncsm m on m.ntno=t.ntno
left outer join ncsb b on b.nmno=m.nmno
where t.ntno=#ncsno#
union all
select count(cmd.cmno) intval,count(distinct d.ndno) intval2
from ncst t
left outer join ncsm m on m.ntno=t.ntno
left outer join ncsb b on b.nmno=m.nmno
left outer join ncsd d on d.nbno=b.nbno
left outer join cmncsd cmd on cmd.ndno=d.ndno
where t.ntno=#ncsno#
union all
select 0 intval,count(u.nuno) intval2
from ncst t
left outer join ncsm m on m.ntno=t.ntno
left outer join ncsb b on b.nmno=m.nmno
left outer join ncsd d on d.nbno=b.nbno
left outer join ncsu u on u.ndno=d.ndno
where t.ntno=#ncsno#
) a
select sum(intval) intval,sum(intval2) intval2
from (
select 0 intval,count(b.nbno) intval2
from ncsm m
left outer join ncsb b on b.nmno=m.nmno
where m.nmno=#ncsno#
union all
select count(cmd.cmno) intval,count(distinct d.ndno) intval2
from ncsm m
left outer join ncsb b on b.nmno=m.nmno
left outer join ncsd d on d.nbno=b.nbno
left outer join cmncsd cmd on cmd.ndno=d.ndno
where m.nmno=#ncsno#
union all
select 0 intval,count(u.nuno) intval2
from ncsm m
left outer join ncsb b on b.nmno=m.nmno
left outer join ncsd d on d.nbno=b.nbno
left outer join ncsu u on u.ndno=d.ndno
where m.nmno=#ncsno#
) a
select sum(intval) intval,sum(intval2) intval2
from (
select count(cmd.cmno) intval,count(distinct d.ndno) intval2
from ncsb b
left outer join ncsd d on d.nbno=b.nbno
left outer join cmncsd cmd on cmd.ndno=d.ndno
where b.nbno=#ncsno#
union all
select 0 intval,count(u.nuno) intval2
from ncsb b
left outer join ncsd d on d.nbno=b.nbno
left outer join ncsu u on u.ndno=d.ndno
where b.nbno=#ncsno#
) a
select sum(intval) intval,sum(intval2) intval2
from (
select count(cmd.cmno) intval,0 intval2
from ncsd d
left outer join cmncsd cmd on cmd.ndno=d.ndno
where d.ndno=#ncsno#
union all
select 0 intval,count(u.nuno) intval2
from ncsd d
left outer join ncsu u on u.ndno=d.ndno
where d.ndno=#ncsno#
) a
delete from ncsu where ndno in (
select d.ndno
from ncst t
inner join ncsm m on m.ntno=t.ntno
inner join ncsb b on b.nmno=m.nmno
inner join ncsd d on d.nbno=b.nbno
where t.ntno=#ncsno#
);
delete from ncsd where nbno in (
select b.nbno
from ncst t
inner join ncsm m on m.ntno=t.ntno
inner join ncsb b on b.nmno=m.nmno
where t.ntno=#ncsno#
);
delete from ncsb where nmno in (
select m.nmno
from ncst t
inner join ncsm m on m.ntno=t.ntno
where t.ntno=#ncsno#
);
delete from ncsm where ntno=#ncsno#;
delete from ncst where ntno=#ncsno#
delete from ncsu where ndno in (
select d.ndno
from ncsm m
inner join ncsb b on b.nmno=m.nmno
inner join ncsd d on d.nbno=b.nbno
where m.nmno=#ncsno#
);
delete from ncsd where nbno in (
select b.nbno
from ncsm m
inner join ncsb b on b.nmno=m.nmno
where m.nmno=#ncsno#
);
delete from ncsb where nmno=#ncsno#;
delete from ncsm where nmno=#ncsno#
delete from ncsu where ndno in (
select d.ndno
from ncsb b
inner join ncsd d on d.nbno=b.nbno
where b.nbno=#ncsno#
);
delete from ncsd where nbno=#ncsno#;
delete from ncsb where nbno=#ncsno#
delete from ncsu where ndno=#ncsno#;
delete from ncsd where ndno=#ncsno#
insert into kcblog (cdt,cp_cd,mobile,vssn,logmsg)
values(now(),#cp_cd#
,case when #mobile# is not null then HEX(AES_ENCRYPT(#mobile#, )) else null end
,#vssn#
,#logmsg#
);