with temp0 as ( select * from School where areaid = #{areaId} ) ,
temp1 as ( select a.schoolid , count( a.classesid ) as classcount
from classes a
where a.areaid = #{areaId} and a.status = 1 and a.classtype = 1
group by a.schoolid ) ,
temp3 as ( select uid from orderinfo
where payway = 0 and isdeleted = 0
and created > #{startTime} and created < #{endTime}
and areaid = #{areaId} ) ,
temp4 as ( select b.uid , max( b.endtime ) as endtime
from UserOwnLesson b
where b.areaid = #{areaId}
and b.uid not in ( select uid from temp3 )
group by b.uid
having max( b.endtime ) < now()
having max( b.endtime ) > now()
) ,
temp2 as ( select a.schoolid ,
count( b.studentid ) as studentcount
from classes a
inner join StudentOwnClass b
on a.status = 1 and a.areaid = #{areaId}
and a.classesid = b.classesid and b.status = 1 and b.areaid = #{areaId}
inner join temp4 c
on b.studentid = c.uid
group by schoolid )
select a.schoolid as objectId , a.schoolname as objectName ,case when b.classcount is null then 0 else b.classcount end as numbercount ,
case when c.studentcount is null then 0 else c.studentcount end as payAmount
from temp0 a
left join temp1 b
on a.schoolid = b.schoolid
left join temp2 c
on a.schoolid = c.schoolid
order by a.schoolid
limit #{pageSize} offset #{offset}
with temp0 as ( select * from Area where parentid = #{areaId} ) ,
temp5 as (select a.parentid, count(a.areaid) as areaCount from area as a inner join temp0 as b on a.parentid = b.areaid
group by a.parentid ),
temp1 as ( select ${floor_str} as areaid ,
count(*) as schoolcount
from School a
where a.status = 1
and a.areaid > #{startArea} and a.areaid < #{endArea}
group by ${floor_str} ),
temp3 as ( select uid from orderinfo
where payway > 0 and ispayed = 1
and isdeleted = 0
and created > #{startTime} and created < #{endTime}
and areaid > #{startArea} and areaid < #{endArea} ) ,
temp4 as ( select b.uid , max( b.endtime ) as endtime
from UserOwnLesson b
inner join StudentOwnClass so on b.uid = so.studentid and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype =1 and c.status= 1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
where b.areaid > #{startArea} and b.areaid < #{endArea}
and b.uid not in ( select uid from temp3 )
group by b.uid
having max( b.endtime ) < now()
having max( b.endtime ) > now()
) ,
temp2 as ( select ${floor_str} as areaid ,
count( a.studentid ) as studentcount
from Student a
inner join temp4 b
on a.status = 1 and a.areaid > #{startArea} and a.areaid < #{endArea}
and a.studentid = b.uid
group by ${floor_str} )
select a.areaid as objectId, a.areaname as objectName ,case when b.schoolcount is null then 0 else b.schoolcount end as numbercount ,
case when c.studentcount is null then 0 else c.studentcount end as payAmount
from temp0 a
left join temp1 b
on a.areaid = b.areaid
left join temp2 c
on a.areaid = c.areaid
order by a.areaid
limit #{pageSize} offset #{offset}
select a.areaid as objectId, a.areaname as objectName ,case when d.areaCount is null then 0 else d.areaCount end as numberCount,
case when c.studentcount is null then 0 else c.studentcount end as payAmount
from temp0 a
left join temp2 c
on a.areaid = c.areaid
left join temp5 d
on d.parentid = a.areaid
order by a.areaid
limit #{pageSize} offset #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
b as ( SELECT a2.parentId , count( distinct a2.areaId ) as numberCount ,
count( st.studentId ) as studentCount
FROM Student as st
INNER JOIN Area as a1
ON st.areaId = a1.areaId
INNER JOIN Area as a2
ON a1.parentId = a2.areaId
GROUP BY a2.parentId ) ,
e as ( SELECT a2.parentId , count( distinct o1.uid ) as payUserCount ,
count(o1.orderInfoId ) as transCount ,
sum( o1.amount ) as payAmount,
sum( o1.fees) as takeAmount, sum(og.years) as yearCount ,
sum( o1.amount - o1.fees ) as accountAmount
FROM ( select orderInfoId ,uid, created , areaId ,
amount , fees
from OrderInfo
where ispayed = 1 and payway > 0
#{startTime}
]]>
) as o1
INNER JOIN OrderOwnGoods as og
on o1.orderInfoId = og.orderInfoId
INNER JOIN Area as a1
on o1.areaId = a1.areaId
INNER JOIN Area as a2
on a1.parentId = a2.areaId
GROUP BY a2.parentId )
SELECT a.areaId as objectId, a.areaName as objectName,
coalesce( b.numberCount , 0 ) as numberCount ,
coalesce( e.payUserCount ,0 ) as payUserCount ,
coalesce( e.transCount , 0 ) as transCount ,
coalesce( e.payAmount , 0 ) as payAmount ,
coalesce( e.takeAmount , 0 ) as takeAmount ,
coalesce( e.accountAmount , 0 ) as accountAmount ,
coalesce( e.yearCount , 0 ) as yearCount
FROM a
LEFT JOIN b
ON a.areaId = b.parentId
LEFT JOIN e
ON a.areaId = e.parentId
ORDER BY a.areaId
LIMIT #{pageSize} OFFSET #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = #{areaId} ) ,
b as ( SELECT a1.parentId , count( distinct a1.areaId ) as numberCount ,
count(st.studentId ) as studentCount
FROM Student as st
INNER JOIN Area as a1
ON st.status = 1 and st.areaId = a1.areaId
INNER JOIN Area as a2
ON a1.parentId = a2.areaId
WHERE a2.parentId = #{areaId}
GROUP BY a1.parentId ) ,
e as ( SELECT a1.parentId , count( distinct o1.uid ) as payUserCount ,
count(o1.orderInfoId ) as transCount ,
sum( o1.amount ) as payAmount,
sum( o1.fees) as takeAmount, sum(og.years) as yearCount ,
sum( o1.amount - o1.fees ) as accountAmount
FROM ( select orderInfoId ,uid, created , areaId ,
amount , fees
from OrderInfo
where ispayed = 1 and payway > 0
#{startTime}
]]>
) as o1
INNER JOIN OrderOwnGoods as og
on o1.orderInfoId = og.orderInfoId
INNER JOIN Area as a1
on o1.areaId = a1.areaId
INNER JOIN Area as a2
on a1.parentId = a2.areaId
WHERE a2.parentId = #{areaId}
GROUP BY a1.parentId )
SELECT a.areaId as objectId, a.areaName as objectName,
coalesce( b.numberCount , 0 ) as numberCount ,
coalesce( e.payUserCount ,0 ) as payUserCount ,
coalesce( e.transCount , 0 ) as transCount ,
coalesce( e.payAmount , 0 ) as payAmount ,
coalesce( e.takeAmount , 0 ) as takeAmount ,
coalesce( e.accountAmount , 0 ) as accountAmount ,
coalesce( e.yearCount , 0 ) as yearCount
FROM a
LEFT JOIN b
ON a.areaId = b.parentId
LEFT JOIN e
ON a.areaId = e.parentId
ORDER BY a.areaId
LIMIT #{pageSize} OFFSET #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = #{areaId} ) ,
b as ( SELECT s.areaid , count( s.schoolId) as numberCount
FROM School as s
INNER JOIN Area as a1
ON s.status = 1 and s.areaId = a1.areaId
WHERE a1.parentId = #{areaId}
GROUP BY s.areaid ) ,
e as ( SELECT a1.areaId , count( distinct o1.uid ) as payUserCount ,
count(o1.orderInfoId ) as transCount ,
sum( o1.amount ) as payAmount,
sum( o1.fees) as takeAmount, sum(og.years) as yearCount ,
sum( o1.amount - o1.fees ) as accountAmount
FROM (
select a.orderInfoId ,a.uid, a.created , c.areaId ,a.amount , a.fees from OrderInfo as a inner join
studentownclass as b on a.uid =b.studentid inner join classes as d on b.classesid = d.classesid inner join
school as c on d.schoolid = c.schoolid where a.ispayed = 1 and a.payway> 0
and a.amount = #{amount}
#{startTime}
]]>
) as o1
INNER JOIN OrderOwnGoods as og
on o1.orderInfoId = og.orderInfoId
INNER JOIN Area as a1
on o1.areaId = a1.areaId
WHERE a1.parentId = #{areaId}
GROUP BY a1.areaId )
SELECT a.areaId as objectId, a.areaName as objectName,
coalesce( b.numberCount , 0 ) as numberCount ,
coalesce( e.payUserCount ,0 ) as payUserCount ,
coalesce( e.transCount , 0 ) as transCount ,
coalesce( e.payAmount , 0 ) as payAmount ,
coalesce( e.takeAmount , 0 ) as takeAmount ,
coalesce( e.accountAmount , 0 ) as accountAmount ,
coalesce( e.yearCount , 0 ) as yearCount
FROM a
LEFT JOIN b
ON a.areaId = b.areaId
LEFT JOIN e
ON a.areaId = e.areaId
ORDER BY a.areaId
LIMIT #{pageSize} OFFSET #{offset}
select count(*) from Area where parentId = #{areaId}
select count(*) from Area where parentId = #{areaId}
WITH a as ( SELECT schoolId , schoolname FROM School
where areaId = #{areaId} and status=1) ,
b as ( SELECT c.schoolId , count( distinct c.classesId) as classCount ,
count(st.studentId ) as studentCount
FROM Student as st
INNER JOIN StudentOwnClass as sc
ON st.status = 1 and st.studentId = sc.studentId
INNER JOIN Classes c
ON sc.classesId = c.classesId and c.status = 1 and c.classtype = 1
WHERE st.areaId = #{areaId}
GROUP BY c.schoolId ) ,
e as ( SELECT c.schoolId , count( distinct o1.uid ) as payUserCount ,
count(o1.orderInfoId ) as transCount ,
sum( o1.amount ) as payAmount,
sum( o1.fees) as takeAmount, sum(og.years) as yearCount ,
sum( o1.amount - o1.fees ) as accountAmount
FROM (
select a.orderInfoId ,a.uid, a.created , c.areaId ,a.amount , a.fees from OrderInfo as a inner join
studentownclass as b on a.uid =b.studentid inner join classes as d on b.classesid = d.classesid inner join
school as c on d.schoolid = c.schoolid where a.ispayed = 1 and a.payway > 0
and a.amount = #{amount}
#{startTime}
]]>
) as o1
INNER JOIN OrderOwnGoods as og
on o1.orderInfoId = og.orderInfoId
INNER JOIN StudentOwnClass as sc
ON o1.uid = sc.studentId
INNER JOIN Classes c
ON sc.classesId = c.classesId and c.status = 1 and c.classtype = 1
WHERE o1.areaId = #{areaId}
GROUP BY c.schoolId ),
f as(
SELECT t.schoolId , count( distinct o1.uid ) as payUserCount ,
count(o1.orderInfoId ) as transCount ,
sum( o1.amount ) as payAmount,
sum( o1.fees) as takeAmount, sum(og.years) as yearCount ,
sum( o1.amount - o1.fees ) as accountAmount
FROM (
select orderInfoId ,uid, created , areaId ,
amount , fees
from OrderInfo
where ispayed = 1 and payway > 0
#{startTime}
]]>
) as o1
INNER JOIN OrderOwnGoods as og
on o1.orderInfoId = og.orderInfoId
inner join teacher t on t.teacherid=o1.uid and t.status=1
and t.areaid=#{areaId} group by t.schoolid
),
g as(select schoolid,sum (payUserCount) payUserCount,sum(transCount) transCount,sum(payAmount) payAmount,
sum(takeAmount) takeAmount,sum(yearCount) yearCount,sum(accountAmount) accountAmount
from (select * from e union all select * from f) as h group by schoolId )
SELECT a.schoolId as objectId, a.schoolname as objectName,
coalesce( b.classCount , 0 ) as numberCount ,
coalesce( b.classCount , 0 ) as classCount ,
coalesce( e.payUserCount ,0 ) as payUserCount ,
coalesce( e.transCount , 0 ) as transCount ,
coalesce( e.payAmount , 0 ) as payAmount ,
coalesce( e.takeAmount , 0 ) as takeAmount ,
coalesce( e.accountAmount , 0 ) as accountAmount ,
coalesce( e.yearCount , 0 ) as yearCount
FROM a
LEFT JOIN b
ON a.schoolId = b.schoolId
LEFT JOIN g e
ON a.schoolId = e.schoolId
ORDER BY a.schoolId
LIMIT #{pageSize} OFFSET #{offset}
select count(*) from School where areaId = #{areaId} and status = 1
select count(*) from Area where parentid = 0
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
b as ( SELECT a2.parentId , count( distinct a2.areaId ) as numberCount ,
count(st.studentId ) as studentCount
FROM Student as st
INNER JOIN Area as a1
ON st.areaId = a1.areaId
INNER JOIN Area as a2
ON a1.parentId = a2.areaId
GROUP BY a2.parentId ) ,
c as ( SELECT a2.parentId ,
count( s.schoolId ) as schoolCount
FROM School as s
INNER JOIN Area as a1
ON s.status = 1 and s.areaId = a1.areaId
INNER JOIN Area as a2
on a1.parentId = a2.areaId
GROUP BY a2.parentId ) ,
d as ( SELECT a2.parentId ,
count( c1.classesId ) as classCount
FROM Classes as c1
INNER JOIN Area as a1
ON c1.status = 1 and c1.classtype =1 and c1.areaId = a1.areaId
INNER JOIN Area as a2
ON a1.parentId = a2.areaId
GROUP BY a2.parentId ) ,
e as ( SELECT a2.parentId ,
count( distinct o1.uid ) as payUserCount ,
sum( o1.amount ) as payAmount, sum(og.years) as yearCount
FROM ( select orderInfoId ,uid, created , areaId , amount
from OrderInfo
where ispayed = 1 and payway > 0
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
#{startTime}
]]>
) as o1
INNER JOIN OrderOwnGoods as og
on o1.orderInfoId = og.orderInfoId
INNER JOIN Area as a1
on o1.areaId = a1.areaId
INNER JOIN Area as a2
on a1.parentId = a2.areaId
GROUP BY a2.parentId ),
f as(
SELECT a2.parentId ,
count( distinct o1.uid ) as payUserCount ,
sum( o1.amount ) as payAmount, sum(cd.months) as monthCount
FROM ( select orderInfoId ,uid, created , areaId , amount,orderno
from OrderInfo
where ispayed = -1 and payway=-100
#{startTime}
]]>
) as o1
INNER JOIN student s
on s.studentid = o1.uid
inner join comppaydetail cd on cd.comppayinfoid=to_number(o1.orderno,'999999999G999D9S')
and cd.recognizecode=s.recognizecode and cd.usertype=1
INNER JOIN Area as a1
on o1.areaId = a1.areaId
INNER JOIN Area as a2
on a1.parentId = a2.areaId
GROUP BY a2.parentId ),
h as(
SELECT a2.parentId ,
count( distinct o1.uid ) as payUserCount
FROM ( select orderInfoId ,uid, created , areaId , amount
from OrderInfo
where (ispayed = 1 or ispayed=-1) and (payway > 0 or payway=-100)
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
#{startTime}
]]>
) as o1
INNER JOIN Area as a1
on o1.areaId = a1.areaId
INNER JOIN Area as a2
on a1.parentId = a2.areaId
GROUP BY a2.parentId),
m as(
select floor( a.areaId / 10000) * 10000 as tempAreaId ,
count(a.uid) as renewCount
from
( select uid,count(uid) payCount,areaid from orderinfo o where created<#{startTime}
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as a
inner join
(select uid,count(uid) payCount,areaid from orderinfo o
where =#{startTime} and created<#{endTime}
]]>
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as b
on a.uid=b.uid
GROUP BY floor( a.areaId / 10000) * 10000)
SELECT a.areaId as objectId, a.areaName as objectName,
coalesce( b.numberCount , 0 ) as numberCount ,
coalesce( c.schoolCount , 0 ) as schoolCount ,
coalesce( d.classCount , 0 ) as classCount ,
coalesce( b.studentCount , 0 ) as studentCount ,
coalesce( e.payUserCount , 0 ) as payUserCount ,
coalesce( e.payAmount , 0 ) as payAmount ,
coalesce( e.yearCount , 0 ) as yearCount,
coalesce( h.payUserCount , 0 ) as payUserAllCount ,
coalesce( f.payUserCount , 0 ) as payUserCashCount ,
coalesce( f.payAmount , 0 ) as payAmountCash,
coalesce( f.monthCount , 0 ) as monthCount,
coalesce( m.renewCount ,0 ) as renewCount
FROM a
LEFT JOIN b
ON a.areaId = b.parentId
LEFT JOIN c
ON a.areaId = c.parentId
LEFT JOIN d
ON a.areaId = d.parentId
LEFT JOIN e
ON a.areaId = e.parentId
LEFT JOIN f
ON a.areaId = f.parentId
LEFT JOIN h
ON a.areaId = h.parentId
LEFT JOIN m
ON a.areaId = m.tempAreaId
ORDER BY a.areaId
LIMIT #{pageSize} OFFSET #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = #{areaId} ) ,
b as ( SELECT a1.parentId , count( distinct a1.areaId ) as numberCount ,
count(st.studentId ) as studentCount
FROM Student as st
INNER JOIN Area as a1
ON st.status = 1 and st.areaId = a1.areaId
INNER JOIN Area as a2
ON a1.parentId = a2.areaId
WHERE a2.parentId = #{areaId}
GROUP BY a1.parentId ) ,
c as ( SELECT a1.parentId ,
count( s.schoolId ) as schoolCount
FROM School as s
INNER JOIN Area as a1
ON s.status = 1 and s.areaId = a1.areaId
INNER JOIN Area as a2
on a1.parentId = a2.areaId
WHERE a2.parentId = #{areaId}
GROUP BY a1.parentId ) ,
d as ( SELECT a1.parentId ,
count( c1.classesId ) as classCount
FROM Classes as c1
INNER JOIN Area as a1
ON c1.status = 1 and c1.classtype =1 and c1.areaId = a1.areaId
INNER JOIN Area as a2
ON a1.parentId = a2.areaId
WHERE a2.parentId = #{areaId}
GROUP BY a1.parentId ) ,
e as ( SELECT a1.parentId ,
count( distinct o1.uid ) as payUserCount ,
sum( o1.amount ) as payAmount, sum(og.years) as yearCount
FROM ( select orderInfoId ,uid, created , areaId , amount
from OrderInfo
where ispayed = 1 and payway > 0
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
#{startTime}
]]>
) as o1
INNER JOIN OrderOwnGoods as og
on o1.orderInfoId = og.orderInfoId
INNER JOIN Area as a1
on o1.areaId = a1.areaId
INNER JOIN Area as a2
on a1.parentId = a2.areaId
WHERE a2.parentId = #{areaId}
GROUP BY a1.parentId ),
f as(
SELECT a1.parentId ,
count( distinct o1.uid ) as payUserCount ,
sum( o1.amount ) as payAmount, sum(cd.months) as monthCount
FROM ( select orderInfoId ,uid, created , areaId , amount,orderno
from OrderInfo
where ispayed = -1 and payway=-100
#{startTime}
]]>
) as o1
INNER JOIN student s
on s.studentid = o1.uid
inner join comppaydetail cd on cd.comppayinfoid=to_number(o1.orderno,'999999999G999D9S')
and cd.recognizecode=s.recognizecode and cd.usertype=1
INNER JOIN Area as a1
on o1.areaId = a1.areaId
INNER JOIN Area as a2
on a1.parentId = a2.areaId
WHERE a2.parentId = #{areaId}
GROUP BY a1.parentId ),
h as(
SELECT a1.parentId ,
count( distinct o1.uid ) as payUserCount
FROM ( select orderInfoId ,uid, created , areaId , amount
from OrderInfo
where (ispayed = 1 or ispayed=-1) and (payway > 0 or payway=-100)
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
#{startTime}
]]>
) as o1
INNER JOIN Area as a1
on o1.areaId = a1.areaId
INNER JOIN Area as a2
on a1.parentId = a2.areaId
WHERE a2.parentId = #{areaId}
GROUP BY a1.parentId),
m as (
select floor( a.areaId / 100) * 100 as tempAreaId ,
count(a.uid) as renewCount
from
( select uid,count(uid) payCount,areaid from orderinfo o
where created<#{startTime}
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and floor( areaId / 10000) * 10000 = #{areaId}
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as a
inner join
(select uid,count(uid) payCount,areaid from orderinfo o
where =#{startTime} and created<#{endTime}
]]>
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and floor( areaId / 10000) * 10000 = #{areaId}
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as b
on a.uid=b.uid
GROUP BY floor( a.areaId / 100) * 100
)
SELECT a.areaId as objectId, a.areaName as objectName,
coalesce( b.numberCount , 0 ) as numberCount ,
coalesce( c.schoolCount , 0 ) as schoolCount,
coalesce( d.classCount , 0 ) as classCount,
coalesce( b.studentCount , 0 ) as studentCount ,
coalesce( e.payUserCount , 0 ) as payUserCount ,
coalesce( e.payAmount , 0 ) as payAmount,
coalesce( e.yearCount , 0 ) as yearCount,
coalesce( h.payUserCount , 0 ) as payUserAllCount ,
coalesce( f.payUserCount , 0 ) as payUserCashCount ,
coalesce( f.payAmount , 0 ) as payAmountCash,
coalesce( f.monthCount , 0 ) as monthCount,
coalesce( m.renewCount ,0 ) as renewCount
FROM a
LEFT JOIN b
ON a.areaId = b.parentId
LEFT JOIN c
ON a.areaId = c.parentId
LEFT JOIN d
ON a.areaId = d.parentId
LEFT JOIN e
ON a.areaId = e.parentId
LEFT JOIN f
ON a.areaId = f.parentId
LEFT JOIN h
ON a.areaId = h.parentId
LEFT JOIN m
ON a.areaId = m.tempAreaId
ORDER BY a.areaId
LIMIT #{pageSize} OFFSET #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = #{areaId} ) ,
b as ( SELECT a1.areaId , count( distinct a1.areaId ) as numberCount ,
count( Distinct st.studentId ) as studentCount
FROM Student as st
INNER JOIN StudentOwnClass as sc
ON st.status = 1 and st.studentId = sc.studentId
INNER JOIN Classes c
ON sc.classesId = c.classesId and c.status = 1
inner join school sl on c.schoolId = sl.schoolId and sl.status=1
INNER JOIN Area as a1
ON st.status = 1 and c.areaId = a1.areaId
WHERE a1.parentId = #{areaId}
GROUP BY a1.areaId ) ,
c as ( SELECT a1.areaId ,
count( s.schoolId ) as schoolCount
FROM School as s
INNER JOIN Area as a1
ON s.status = 1 and s.areaId = a1.areaId
WHERE a1.parentId = #{areaId}
GROUP BY a1.areaId ) ,
d as ( SELECT a1.areaId ,
count( c1.classesId ) as classCount
FROM Classes as c1
INNER JOIN Area as a1
ON c1.status = 1 and c1.classtype =1 and c1.areaId = a1.areaId
WHERE a1.parentId = #{areaId}
GROUP BY a1.areaId ) ,
e as ( SELECT a1.areaId ,
count( distinct o1.uid ) as payUserCount ,
sum( o1.amount ) as payAmount, sum(og.years) as yearCount
FROM ( select orderInfoId ,uid, created , areaId , amount
from OrderInfo
where ispayed = 1 and payway > 0
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
#{startTime}
]]>
) as o1
INNER JOIN OrderOwnGoods as og
on o1.orderInfoId = og.orderInfoId
INNER JOIN Area as a1
on o1.areaId = a1.areaId
WHERE a1.parentId = #{areaId}
GROUP BY a1.areaId ),
f as(
SELECT a1.areaId ,
count( distinct o1.uid ) as payUserCount ,
sum( o1.amount ) as payAmount, sum(cd.months) as monthCount
FROM ( select orderInfoId ,uid, created , areaId , amount,orderno
from OrderInfo
where ispayed = -1 and payway=-100 and amount >0
#{startTime}
]]>
) as o1
INNER JOIN student s
on s.studentid = o1.uid
inner join comppaydetail cd on cd.comppayinfoid=to_number(o1.orderno,'999999999G999D9S')
and cd.recognizecode=s.recognizecode and cd.usertype=1
INNER JOIN Area as a1
on o1.areaId = a1.areaId
WHERE a1.parentId = #{areaId}
GROUP BY a1.areaId ),
h as(
SELECT a1.areaId ,
count( distinct o1.uid ) as payUserCount
FROM ( select orderInfoId ,uid, created , areaId , amount
from OrderInfo
where (ispayed = 1 or ispayed=-1) and (payway > 0 or payway=-100)
#{startTime}
]]>
) as o1
INNER JOIN Area as a1
on o1.areaId = a1.areaId
WHERE a1.parentId = #{areaId}
GROUP BY a1.areaId),
m as (select a.areaId,
count(a.uid) as renewCount
from
( select uid,count(uid) payCount,areaid from orderinfo o
where created<#{startTime}
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and floor( areaId / 100) * 100 = #{areaId}
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as a
inner join
(select uid,count(uid) payCount,areaid from orderinfo o
where =#{startTime} and created<#{endTime}
]]>
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and floor( areaId / 100) * 100 = #{areaId}
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as b
on a.uid=b.uid
GROUP BY a.areaId )
SELECT a.areaId as objectId, a.areaName as objectName,
coalesce( b.numberCount , 0 ) as numberCount,
coalesce( c.schoolCount , 0 ) as schoolCount,
coalesce( d.classCount , 0 ) as classCount,
coalesce( b.studentCount , 0 ) as studentCount,
coalesce( e.payUserCount , 0 ) as payUserCount ,
coalesce( e.payAmount , 0 ) as payAmount,
coalesce( e.yearCount , 0 ) as yearCount,
coalesce( h.payUserCount , 0 ) as payUserAllCount ,
coalesce( f.payUserCount , 0 ) as payUserCashCount ,
coalesce( f.payAmount , 0 ) as payAmountCash,
coalesce( f.monthCount , 0 ) as monthCount,
coalesce( m.renewCount ,0 ) as renewCount
FROM a
LEFT JOIN b
ON a.areaId = b.areaId
LEFT JOIN c
ON a.areaId = c.areaId
LEFT JOIN d
ON a.areaId = d.areaId
LEFT JOIN e
ON a.areaId = e.areaId
LEFT JOIN f
ON a.areaId = f.areaId
LEFT JOIN h
ON a.areaId = h.areaId
LEFT JOIN m
ON a.areaId = m.areaId
ORDER BY a.areaId
LIMIT #{pageSize} OFFSET #{offset}
WITH a as ( SELECT schoolId , schoolname FROM School
where areaId = #{areaId} and status = 1 ) ,
b as ( SELECT c.schoolId , count( distinct c.schoolId) as numberCount ,
count(Distinct st.studentId ) as studentCount
FROM Student as st
INNER JOIN StudentOwnClass as sc
ON st.status = 1 and st.studentId = sc.studentId
INNER JOIN Classes c
ON sc.classesId = c.classesId and c.status = 1
WHERE st.areaId = #{areaId}
GROUP BY c.schoolId ) ,
d as ( SELECT c1.schoolId ,
count( c1.classesId ) as classCount
FROM Classes as c1
WHERE c1.areaId = #{areaId}
AND c1.status = 1 and c1.classtype =1
GROUP BY c1.schoolId ) ,
e as ( SELECT c.schoolId ,
count( distinct o1.uid ) as payUserCount ,
sum( o1.amount ) as payAmount, sum(og.years) as yearCount
FROM ( select orderInfoId ,uid, created , areaId , amount
from OrderInfo
where ispayed = 1 and payway > 0
#{startTime}
]]>
) as o1
INNER JOIN OrderOwnGoods as og
on o1.orderInfoId = og.orderInfoId
INNER JOIN StudentOwnClass as sc
ON o1.uid = sc.studentId
INNER JOIN Classes c
ON sc.classesId = c.classesId and c.status = 1 and c.classtype = 1
WHERE o1.areaId = #{areaId}
GROUP BY c.schoolId ),
i as(
SELECT c.schoolId ,
count( distinct o1.uid ) as payUserCount ,
sum( o1.amount ) as payAmount, sum(cd.months) as monthCount
FROM ( select orderInfoId ,uid, created , areaId , amount,orderno
from OrderInfo
where ispayed = -1 and payway=-100 and amount > 0
#{startTime}
]]>
) as o1
INNER JOIN student s
on s.studentid = o1.uid
inner join comppaydetail cd on cd.comppayinfoid=to_number(o1.orderno,'999999999G999D9S')
and cd.recognizecode=s.recognizecode and cd.usertype=1
INNER JOIN StudentOwnClass as sc
ON o1.uid = sc.studentId
INNER JOIN Classes c
ON sc.classesId = c.classesId and c.status = 1 and c.classtype = 1
WHERE o1.areaId = #{areaId}
GROUP BY c.schoolId ),
h as( select schoolId,count( distinct uid ) as payUserCount from
( select orderInfoId ,uid, created , areaId , amount
from OrderInfo
where (ispayed = 1 or ispayed=-1) and (payway > 0 or payway=-100) and amount > 0
#{startTime}
]]>
and areaid=#{areaId}
) as o1
INNER JOIN StudentOwnClass as sc
ON o1.uid = sc.studentId
INNER JOIN Classes c
ON sc.classesId = c.classesId and c.status = 1 and c.classtype = 1
group by schoolId
),
m as (select a.schoolId,
count(a.uid) as renewCount
from
( select uid,count(uid) payCount,c.schoolId from orderinfo o
inner join studentownclass soc on soc.studentid=o.uid
and o.created<#{startTime}
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100) and amount > 0
and o.areaId = #{areaId} and soc.status=1
inner join classes c on c.classesid=soc.classesid and c.classtype=1
group by o.uid,c.schoolId ) as a
inner join
(select uid,count(uid) payCount,c.schoolId from orderinfo o
inner join studentownclass soc on soc.studentid=o.uid
and =#{startTime} and created<#{endTime}
]]>
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100) and o.amount > 0
and o.areaId = #{areaId} and soc.status=1
inner join classes c on c.classesid=soc.classesid and c.classtype=1
group by o.uid,c.schoolId ) as b
on a.uid=b.uid
GROUP BY a.schoolId)
SELECT a.schoolId as objectId, a.schoolName as objectName,
coalesce( d.classCount , 0 ) as numberCount ,
coalesce( b.numberCount , 0 ) as schoolCount ,
coalesce( d.classCount , 0 ) as classCount ,
coalesce( b.studentCount , 0 ) as studentCount ,
coalesce( e.payUserCount , 0 ) as payUserCount ,
coalesce( e.payAmount , 0 ) as payAmount ,
coalesce( e.yearCount , 0 ) as yearCount,
coalesce( h.payUserCount , 0 ) as payUserAllCount ,
coalesce( i.payUserCount , 0 ) as payUserCashCount ,
coalesce( i.payAmount , 0 ) as payAmountCash,
coalesce( i.monthCount , 0 ) as monthCount,
coalesce( m.renewCount ,0 ) as renewCount
FROM a
LEFT JOIN b
ON a.schoolId = b.schoolId
LEFT JOIN d
ON a.schoolId = d.schoolId
LEFT JOIN e
ON a.schoolId = e.schoolId
LEFT JOIN i
ON a.schoolId = i.schoolId
LEFT JOIN h
ON a.schoolId = h.schoolId
LEFT JOIN m
ON a.schoolId = m.schoolId
ORDER BY a.schoolId
LIMIT #{pageSize} OFFSET #{offset}
select distinct(a.areaId) as objectId, a.areaName as objectName, count(distinct(b.areaid)) as numberCount ,
count(distinct(uo.uid)) as payAmount
from Area a
inner join Area b on a.areaid = b.parentid
inner join Area d on b.areaid = d.parentid
left join school s on d.areaId = s.areaid and s.status=1
left join (select distinct(uid), min(uo.startTime) as startTime , max(uo.endTime) as endTime ,max(c.schoolid) as schoolid
from UserOwnLesson uo
inner join StudentOwnClass so on uo.uid = so.studentid and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype =1 and c.status= 1
group by uid
) uo on uo.schoolid = s.schoolid
and uo.uid in
(select s.studentId from Student s
inner join StudentOwnClass so on so.studentId = s.studentId and so.status =1
inner join Classes c on c.classesId = so.classesId and c.classtype = 1 and c.status= 1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid
inner join area b on b.areaid = a.parentid
inner join Area d on b.areaid = d.parentid
where s.studentId not in (select uid from orderinfo where payway >0 and ispayed = 1
#{startTime}
]]>
))
and uo.endTime < now()
group by a.areaid
order by a.areaid
limit #{pageSize} offset #{offset}
select distinct(a.areaId) as objectId, a.areaName as objectName, count(distinct(b.areaid)) as numberCount ,
count(distinct(uo.uid)) as payAmount
from Area a
inner join Area b on a.areaid = b.parentid
left join school s on b.areaId = s.areaid and s.status=1
left join (select distinct(uid), min(uo.startTime) as startTime , max(uo.endTime) as endTime ,max(c.schoolid) as schoolid
from UserOwnLesson uo
inner join StudentOwnClass so on uo.uid = so.studentid and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype =1 and c.status= 1
group by uid
) uo on uo.schoolid = s.schoolid
and uo.uid in
(select s.studentId from Student s
inner join StudentOwnClass so on so.studentId = s.studentId and so.status =1
inner join Classes c on c.classesId = so.classesId and c.classtype = 1 and c.status= 1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid
inner join area b on b.areaid = a.parentid and b.parentId= #{areaId}
where s.studentId not in (select uid from orderinfo where payway >0 and ispayed = 1
#{startTime}
]]>
))
and uo.endTime < now()
where a.parentid = #{areaId}
group by a.areaid
order by a.areaid
limit #{pageSize} offset #{offset}
select distinct(a.areaId) as objectId, a.areaName as objectName, count(distinct(s.schoolid)) as numberCount ,
count(distinct(uo.uid)) as payAmount
from Area a left join school s on a.areaId = s.areaid and s.status=1
left join (select distinct(uid), min(uo.startTime) as startTime , max(uo.endTime) as endTime ,max(c.schoolid) as schoolid
from UserOwnLesson uo
inner join StudentOwnClass so on uo.uid = so.studentid and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype =1 and c.status= 1
group by uid
) uo on uo.schoolid = s.schoolid
and uo.uid in
(select s.studentId from Student s
inner join StudentOwnClass so on so.studentId = s.studentId and so.status =1
inner join Classes c on c.classesId = so.classesId and c.classtype = 1 and c.status= 1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid and a.parentId= #{areaId}
where s.studentId not in (select uid from orderinfo where payway >0 and ispayed = 1
#{startTime}
]]>
))
and uo.endTime < now()
where a.parentid = #{areaId}
group by a.areaid
order by a.areaid
limit #{pageSize} offset #{offset}
select distinct(s.schoolId) as objectId, s.schoolName as objectName , count(distinct(c.classesId)) as numberCount ,
count(distinct(uo.uid)) as payAmount
from school s
left join classes c on s.schoolid = c.schoolid and c.classtype = 1 and c.status =1 and s.status=1
left join (select distinct(uid), min(uo.startTime) as startTime , max(uo.endTime) as endTime ,min(so.classesid) as classesid
from UserOwnLesson uo
inner join StudentOwnClass so on uo.uid = so.studentid and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype =1 and c.status =1
group by uid
) uo on uo.classesid = c.classesid
and uo.uid in
(select s.studentId from Student s
inner join StudentOwnClass so on so.studentId = s.studentId and so.status =1
inner join Classes c on c.classesId = so.classesId and c.classtype = 1 and c.status =1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid and a.areaid= #{areaId}
where s.studentId not in (select uid from orderinfo where payway >0 and ispayed = 1
#{startTime}
]]>
))
and uo.endTime < now()
where s.areaid = #{areaId} and s.status=1
group by s.schoolId
order by s.schoolId
limit #{pageSize} offset #{offset}
select distinct(a.areaId) as objectId, a.areaName as objectName, count(distinct(b.areaid)) as numberCount ,
count(distinct(uo.uid)) as payAmount
from Area a
inner join Area b on a.areaid = b.parentid
inner join Area d on b.areaid = d.parentid
left join school s on d.areaId = s.areaid and s.status=1
left join (select distinct(uid), min(uo.startTime) as startTime , max(uo.endTime) as endTime ,max(c.schoolid) as schoolid
from UserOwnLesson uo
inner join StudentOwnClass so on uo.uid = so.studentid and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype =1 and c.status= 1
group by uid
) uo on uo.schoolid = s.schoolid
and uo.uid in
(select s.studentId from Student s
inner join StudentOwnClass so on so.studentId = s.studentId and so.status =1
inner join Classes c on c.classesId = so.classesId and c.classtype = 1 and c.status= 1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid
inner join area b on b.areaid = a.parentid
inner join Area d on b.areaid = d.parentid
where s.studentId not in (select uid from orderinfo where payway >0 and ispayed = 1
#{startTime}
]]>
))
and uo.endTime >= now()
and uo.endTime is not null
group by a.areaid
order by a.areaid
limit #{pageSize} offset #{offset}
select distinct(a.areaId) as objectId, a.areaName as objectName, count(distinct(b.areaid)) as numberCount ,
count(distinct(uo.uid)) as payAmount
from Area a
inner join Area b on a.areaid = b.parentid
left join school s on b.areaId = s.areaid and s.status=1
left join (select distinct(uid), min(uo.startTime) as startTime , max(uo.endTime) as endTime ,max(c.schoolid) as schoolid
from UserOwnLesson uo
inner join StudentOwnClass so on uo.uid = so.studentid and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype =1 and c.status= 1
group by uid
) uo on uo.schoolid = s.schoolid
and uo.uid in
(select s.studentId from Student s
inner join StudentOwnClass so on so.studentId = s.studentId and so.status =1
inner join Classes c on c.classesId = so.classesId and c.classtype = 1 and c.status= 1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid
inner join area b on b.areaid = a.parentid and b.parentId= #{areaId}
where s.studentId not in (select uid from orderinfo where payway >0 and ispayed = 1
#{startTime}
]]>
))
and uo.endTime >= now()
and uo.endTime is not null
where a.parentid = #{areaId}
group by a.areaid
order by a.areaid
limit #{pageSize} offset #{offset}
select distinct(a.areaId) as objectId, a.areaName as objectName, count(distinct(s.schoolid)) as numberCount ,
count(distinct(uo.uid)) as payAmount
from Area a left join school s on a.areaId = s.areaid and s.status=1
left join (select distinct(uid), min(uo.startTime) as startTime , max(uo.endTime) as endTime ,max(c.schoolid) as schoolid
from UserOwnLesson uo
inner join StudentOwnClass so on uo.uid = so.studentid and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype =1 and c.status =1
group by uid
) uo on uo.schoolid = s.schoolid
and uo.uid in
(select s.studentId from Student s
inner join StudentOwnClass so on uo.uid = so.studentid and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype =1 and c.status =1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid and a.parentId= #{areaId}
where s.studentId not in (select uid from orderinfo where payway >0 and ispayed = 1
#{startTime}
]]>
))
and uo.endTime >= now()
and uo.endTime is not null
where a.parentid = #{areaId}
group by a.areaid
order by a.areaid
limit #{pageSize} offset #{offset}
select distinct(s.schoolId) as objectId, s.schoolName as objectName , count(distinct(c.classesId)) as numberCount ,
count(distinct(uo.uid)) as payAmount
from school s
left join classes c on s.schoolid = c.schoolid and c.classtype = 1 and c.status =1 and s.status=1
left join (select distinct(uid), min(uo.startTime) as startTime , max(uo.endTime) as endTime ,min(so.classesid) as classesid
from UserOwnLesson uo
inner join StudentOwnClass so on uo.uid = so.studentid and so.status = 1 and uo.areaid=#{areaId}
inner join Classes c on c.classesid = so.classesid and c.classtype = 1 and c.status = 1
group by uid
) uo on uo.classesid = c.classesid
and uo.uid in
(select s.studentId from Student s
inner join StudentOwnClass so on uo.uid = so.studentid and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype =1 and c.status =1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
and sc.areaid= #{areaId}
where s.studentId not in (select uid from orderinfo where payway >0 and ispayed = 1
#{startTime}
]]>
))
and uo.endTime >= now()
and uo.endTime is not null
where s.areaid = #{areaId} and s.status=1
group by s.schoolId
order by s.schoolId
limit #{pageSize} offset #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
b as ( SELECT floor( areaId / 10000 ) * 10000 as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
GROUP BY floor( areaId / 10000 ) * 10000 ),
c as ( SELECT floor( areaId / 10000 ) * 10000 as tempAreaId ,
count( studentId ) as studentCount
FROM Student
GROUP BY floor( areaId / 10000 ) * 10000 )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
ORDER BY a.areaId
limit #{pageSize} offset #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = #{areaId} ) ,
b as ( SELECT floor( areaId / 100 ) * 100 as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
AND floor( areaId / 10000 ) * 10000 = #{areaId}
GROUP BY floor( areaId / 100 ) * 100 ),
c as ( SELECT floor( areaId / 100 ) * 100 as tempAreaId ,
count( studentId ) as studentCount
FROM Student
WHERE floor( areaId / 10000 ) * 10000 = #{areaId}
GROUP BY floor( areaId / 100 ) * 100 )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
ORDER BY a.areaId
limit #{pageSize} offset #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = #{areaId} ) ,
b as ( SELECT areaId as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
AND floor( areaId / 100 ) * 100 = #{areaId}
GROUP BY areaId ),
c as ( SELECT areaId as tempAreaId ,
count( studentId ) as studentCount
FROM Student
WHERE floor( areaId / 100 ) * 100 = #{areaId}
GROUP BY areaId )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
ORDER BY a.areaId
limit #{pageSize} offset #{offset}
select s.schoolId as objectId, s.schoolName as objectName,
count(distinct c.classesId) as numberCount ,
count(distinct sc.studentId) as payAmount
from School s
inner join Classes c
on s.schoolId = c.schoolId and c.classtype = 1 and c.status =1 and s.status=1
inner join StudentOwnClass sc
on sc.classesId = c.classesId and sc.status =1 inner join student st on st.studentId = sc.studentId and st.status =1
where s.areaid = #{areaId} and s.status=1
group by s.schoolId , s.schoolName
order by s.schoolId
limit #{pageSize} offset #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
b as ( SELECT floor( areaId / 10000 ) * 10000 as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
GROUP BY floor( areaId / 10000 ) * 10000 ),
c as ( SELECT floor( areaId / 10000 ) * 10000 as tempAreaId ,
count( teacherId ) as studentCount
FROM Teacher
GROUP BY floor( areaId / 10000 ) * 10000 )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
ORDER BY a.areaId
limit #{pageSize} offset #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = #{areaId} ) ,
b as ( SELECT floor( areaId / 100 ) * 100 as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
AND floor( areaId / 10000 ) * 10000 = #{areaId}
GROUP BY floor( areaId / 100 ) * 100 ),
c as ( SELECT floor( areaId / 100 ) * 100 as tempAreaId ,
count( teacherId ) as studentCount
FROM Teacher
WHERE floor( areaId / 10000 ) * 10000 = #{areaId}
GROUP BY floor( areaId / 100 ) * 100 )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
ORDER BY a.areaId
limit #{pageSize} offset #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = #{areaId} ) ,
b as ( SELECT areaId as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
AND floor( areaId / 100 ) * 100 = #{areaId}
GROUP BY areaId ),
c as ( SELECT areaId as tempAreaId ,
count( teacherId ) as studentCount
FROM Teacher
WHERE floor( areaId / 100 ) * 100 = #{areaId}
GROUP BY areaId )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
ORDER BY a.areaId
limit #{pageSize} offset #{offset}
with ss as ( select schoolId as objectId, schoolName as objectName
from School
where areaid = #{areaId} and status = 1
order by schoolId
LIMIT #{pageSize}
OFFSET #{offset}
)
select ss.objectId , ss.objectName ,
case when m.numberCount >0 then
m.numberCount else 0 end as numberCount ,
case when n.payAmount >0 then
n.payAmount else 0 end as payAmount
from SS
left join ( select a.objectId , count( b.classesId ) as numberCount
from SS as a
inner join Classes b
on b.schoolId = a.objectid
and b.status = 1
group by a.objectId ) as m
on ss.objectId = m.objectId
left join ( select a.objectId , count( t.teacherId ) as payAmount
from SS as a
inner join Teacher t
on t.schoolId = a.objectId and t.status = 1
group by a.objectId ) as n
on ss.objectId = n.objectId
order by ss.objectId
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
b as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
GROUP BY floor( areaId / 10000) * 10000 ),
c as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as studentCount
FROM Student
GROUP BY floor( areaId / 10000) * 10000 ) ,
e as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( distinct uid ) as payUserCount
FROM Orderinfo
WHERE
ispayed = 1 and payway > 0
#{startTime}
]]>
GROUP BY floor( areaId / 10000) * 10000 )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount ,
coalesce( e.payUserCount ,0 ) as payUserCount ,
coalesce( e.payUserCount ,0 ) as takeAmount ,
case when coalesce( c.studentCount ,0 ) = 0 then 0.0000 else
round(coalesce( e.payUserCount ,0 )*100::numeric/c.studentCount::numeric , 2 ) end
as accountAmount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
LEFT JOIN e
ON a.areaId = e.tempAreaId
ORDER BY a.areaId
limit #{pageSize} offset #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = #{areaId} ) ,
b as ( SELECT floor( areaId / 100) * 100 as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
AND floor( areaId / 10000 ) * 10000 = #{areaId}
GROUP BY floor( areaId / 100) * 100 ),
c as ( SELECT floor( areaId / 100) * 100 as tempAreaId ,
count( studentId ) as studentCount
FROM Student
WHERE floor( areaId / 10000 ) * 10000 = #{areaId}
GROUP BY floor( areaId / 100) * 100 ) ,
e as ( SELECT floor( areaId / 100) * 100 as tempAreaId ,
count( distinct uid ) as payUserCount
FROM Orderinfo
WHERE floor( areaId / 10000 ) * 10000 = #{areaId}
AND
ispayed = 1 and payway > 0
#{startTime}
]]>
GROUP BY floor( areaId / 100) * 100 )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount ,
coalesce( e.payUserCount ,0 ) as payUserCount ,
coalesce( e.payUserCount ,0 ) as takeAmount ,
case when coalesce( c.studentCount ,0 ) = 0 then 0.0000 else
round(coalesce( e.payUserCount ,0 )*100::numeric/c.studentCount::numeric,2 ) end
as accountAmount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
LEFT JOIN e
ON a.areaId = e.tempAreaId
ORDER BY a.areaId
limit #{pageSize} offset #{offset}
select distinct(a.areaId) as objectId, a.areaName as objectName, count(distinct(s.schoolId)) as numberCount ,
count(distinct(ss.studentId)) as payAmount ,count(distinct(o.uid)) as takeAmount ,
case when count(distinct(ss.studentId)) = 0 then 0.0000 else
round(count(distinct(o.uid))*100::numeric/count(distinct(ss.studentId)::numeric),4) end as accountAmount
from Area a
left join School s on s.areaId = a.areaId and s.status=1
left join (
select s.studentId , sc.schoolId from Student s
inner join StudentOwnClass so on so.studentId = s.studentId and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype = 1 and c.status = 1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid and a.parentId= #{areaId}
) ss on ss.schoolId = s.schoolId
left join OrderInfo o on o.uid = ss.studentId and o.ispayed =1 and o.payway >0
#{startTime}
]]>
left join OrderOwnGoods oo on o.orderInfoId = oo.orderInfoId
left join Goods g on g.goodsId = oo.goodsId
where a.parentid = #{areaId}
group by a.areaid
order by a.areaid
limit #{pageSize} offset #{offset}
select distinct(s.schoolId) as objectId, s.schoolName as objectName, count(distinct(c.classesId)) as numberCount ,
count(distinct(ss.studentId)) as payAmount ,count(distinct(o.uid)) as takeAmount ,
case when count(distinct(ss.studentId)) = 0 then 0.0000 else
round(count(distinct(o.uid))*100::numeric/count(distinct(ss.studentId)::numeric),4) end as accountAmount
from School s
left join Classes c on c.schoolId = s.schoolId and s.status = 1
left join (
select s.studentId , c.classesId from Student s
inner join StudentOwnClass so on so.studentId = s.studentId and so.status = 1
inner join Classes c on c.classesId = so.classesId and c.classtype = 1 and c.status = 1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid and a.areaid= #{areaId}
) ss on ss.classesId = c.classesId
left join OrderInfo o on o.uid = ss.studentId and o.ispayed =1 and o.payway >0
#{startTime}
]]>
left join OrderOwnGoods oo on o.orderInfoId = oo.orderInfoId
left join Goods g on g.goodsId = oo.goodsId
where s.areaId = #{areaId} and s.status=1
group by s.schoolId
order by s.schoolId
limit #{pageSize} offset #{offset}
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
b as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
GROUP BY floor( areaId / 10000) * 10000 )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount from a left join b ON a.areaId = b.tempAreaId ORDER BY a.areaId
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
c as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as studentCount
FROM Student where status = 1
GROUP BY floor( areaId / 10000) * 10000 ) ,
f as ( SELECT floor( M.areaId / 10000) * 10000 as tempAreaId ,
count( distinct M.studentId ) as takeAmount
FROM Student M
WHERE M.lastsignin is not null and status = 1
GROUP BY floor( M.areaId / 10000) * 10000 )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount ,
coalesce( f.takeAmount ,0 ) as takeAmount ,
case when coalesce( c.studentCount ,0 ) = 0 then 0.00
when coalesce( f.takeAmount ,0 ) = 0 then 0.00
else
round( (f.takeAmount * 100)::numeric / c.studentCount::numeric , 2 )
end as accountAmount
FROM a
LEFT JOIN c
ON a.areaId = c.tempAreaId
LEFT JOIN f
ON a.areaId = f.tempAreaId
ORDER BY a.areaId
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
g as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as activeAmount
FROM Student
WHERE
lastsignin>now()-interval '1 month'
and status = 1
GROUP BY floor( areaId / 10000) * 10000 )
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( g.activeAmount ,0 ) as activeAmount
from a
LEFT JOIN g
ON a.areaId = g.tempAreaId
ORDER BY a.areaId
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
h as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as weekActiveAmount
FROM Student
WHERE
lastsignin>now()-interval '1 week'
and status = 1
GROUP BY floor( areaId / 10000) * 10000 )
select a.areaId as objectId , a.areaName as objectName,
coalesce( h.weekActiveAmount ,0 ) as weekActiveAmount
from a
LEFT JOIN h
ON a.areaId = h.tempAreaId
ORDER BY a.areaId
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
i as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as dayActiveAmount
FROM Student
WHERE
lastsignin>now()-interval '1 day'
and status = 1
GROUP BY floor( areaId / 10000) * 10000 )
select a.areaId as objectId , a.areaName as objectName, coalesce( i.dayActiveAmount ,0 ) as dayActiveAmount
from a
LEFT JOIN i
ON a.areaId =i.tempAreaId
ORDER BY a.areaId
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
b as (select distinct c.uid from connectlog c where = #{startTime} and c.startTime<#{endTime}
]]>),
j as (select floor( s.areaId / 10000) * 10000 as tempAreaId ,
count( b.uid ) as useAmount from b inner join student as s on s.studentid = b.uid where s.status =1 group by floor( s.areaId / 10000) * 10000 )
select a.areaId as objectId , a.areaName as objectName, coalesce( j.useAmount ,0 ) as useAmount
from a
LEFT JOIN j
ON a.areaId =j.tempAreaId
ORDER BY a.areaId
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
s as (SELECT areaId , studentId
FROM Student
where =#{startTime} and created<#{endTime}
]]>
and status=1),
k as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as studentbytimeCount
FROM s
GROUP BY floor( areaId / 10000) * 10000 ),
cn as ( select distinct uid from connectlog where =#{startTime} and endtime <#{endTime}
]]>
),
l as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,count( studentId ) as studentLoginbytimeCount from cn inner join s on s.studentid = cn.uid group by floor( areaId / 10000) * 10000 )
select a.areaId as objectId , a.areaName as objectName,
coalesce( k.studentbytimeCount ,0 ) as studentbytimeCount,
case when coalesce( k.studentbytimeCount ,0 ) = 0 then 0.00
when coalesce( l.studentLoginbytimeCount ,0 ) = 0 then 0.00 else
round( (l.studentLoginbytimeCount * 100)::numeric / k.studentbytimeCount::numeric , 2 )
end as accountAmountbyTime
from a
LEFT JOIN k
ON a.areaId =k.tempAreaId
left join l
on a.areaId = l.tempAreaId
ORDER BY a.areaId
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
m as(select floor( a.areaId / 10000) * 10000 as tempAreaId ,
count(a.uid) as renewCount
from
( select uid,count(uid) payCount,areaid from orderinfo o where created<#{startTime}
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as a
inner join
(select uid,count(uid) payCount,areaid from orderinfo o
where =#{startTime} and created<#{endTime}
]]>
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as b
on a.uid=b.uid
GROUP BY floor( a.areaId / 10000) * 10000)
SELECT a.areaId as objectId , a.areaName as objectName, coalesce(m.renewCount ,0 ) as renewCount
from a
LEFT JOIN m
ON a.areaId = m.tempAreaId
ORDER BY a.areaId
WITH a as ( SELECT areaId , areaname FROM Area where areaId = #{areaId}) ,
b as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1 and floor( areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( areaId / 10000) * 10000 ),
c as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as studentCount
FROM Student where status = 1 and floor( areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( areaId / 10000) * 10000 ) ,
f as ( SELECT floor( M.areaId / 10000) * 10000 as tempAreaId ,
count( distinct M.studentId ) as takeAmount
FROM Student M
WHERE M.lastsignin is not null and status = 1 and floor( M.areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( M.areaId / 10000) * 10000 ) ,
g as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as activeAmount
FROM Student
WHERE
lastsignin>now()-interval '1 month'
and status = 1 and floor( areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( areaId / 10000) * 10000 ),
h as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as weekActiveAmount
FROM Student
WHERE
lastsignin>now()-interval '1 week'
and status = 1 and floor( areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( areaId / 10000) * 10000 ),
i as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as dayActiveAmount
FROM Student
WHERE
lastsignin>now()-interval '1 day'
and status = 1 and floor( areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( areaId / 10000) * 10000 ) ,
j as ( SELECT floor( c.areaId / 10000) * 10000 as tempAreaId ,
count( distinct c.uid ) as useAmount
FROM connectlog c inner join student s on c.uid=s.studentid
and
=#{startTime} and endTime<#{endTime} and s.status=1
]]>
and floor( c.areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( c.areaId / 10000) * 10000 ),
k as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as studentbytimeCount
FROM Student
where =#{startTime} and created<#{endTime}
]]>
and status=1 and floor( areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( areaId / 10000) * 10000 ) ,
cn as ( select distinct uid from connectlog where =#{startTime} and endtime <#{endTime}
]]>
),
l as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as studentLoginbytimeCount
FROM cn inner join Student on studentid=cn.uid
where =#{startTime} and created<#{endTime}
]]>
and status=1 and floor( areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( areaId / 10000) * 10000 ),
m as(select floor( a.areaId / 10000) * 10000 as tempAreaId ,
count(a.uid) as renewCount
from
( select uid,count(uid) payCount,areaid from orderinfo o where created<#{startTime}
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as a
inner join
(select uid,count(uid) payCount,areaid from orderinfo o
where =#{startTime} and created<#{endTime}
]]>
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as b
on a.uid=b.uid and floor( a.areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( a.areaId / 10000) * 10000)
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount ,
coalesce( f.takeAmount ,0 ) as takeAmount ,
case when coalesce( c.studentCount ,0 ) = 0 then 0.00
when coalesce( f.takeAmount ,0 ) = 0 then 0.00
else
round( (f.takeAmount * 100)::numeric / c.studentCount::numeric , 2 )
end as accountAmount ,
coalesce( g.activeAmount ,0 ) as activeAmount,
coalesce( h.weekActiveAmount ,0 ) as weekActiveAmount,
coalesce( i.dayActiveAmount ,0 ) as dayActiveAmount,
coalesce( j.useAmount ,0 ) as useAmount,
coalesce( k.studentbytimeCount ,0 ) as studentbytimeCount,
case when coalesce( k.studentbytimeCount ,0 ) = 0 then 0.00
when coalesce( l.studentLoginbytimeCount ,0 ) = 0 then 0.00 else
round( (l.studentLoginbytimeCount * 100)::numeric / k.studentbytimeCount::numeric , 2 )
end as accountAmountbyTime ,
coalesce(m.renewCount ,0 ) as renewCount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
LEFT JOIN f
ON a.areaId = f.tempAreaId
LEFT JOIN g
ON a.areaId = g.tempAreaId
LEFT JOIN h
ON a.areaId = h.tempAreaId
LEFT JOIN i
ON a.areaId = i.tempAreaId
LEFT JOIN j
ON a.areaId = j.tempAreaId
LEFT JOIN k
ON a.areaId = k.tempAreaId
LEFT JOIN l
ON a.areaId = l.tempAreaId
LEFT JOIN m
ON a.areaId = m.tempAreaId
ORDER BY a.areaId
WITH a as ( SELECT areaId , areaname FROM Area where parentId = 0 ) ,
b as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
GROUP BY floor( areaId / 10000) * 10000 ),
c as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as studentCount
FROM Student where status = 1
GROUP BY floor( areaId / 10000) * 10000 ) ,
f as ( SELECT floor( M.areaId / 10000) * 10000 as tempAreaId ,
count( distinct M.studentId ) as takeAmount
FROM Student M
WHERE M.lastsignin is not null and status = 1
GROUP BY floor( M.areaId / 10000) * 10000 ) ,
g as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as activeAmount
FROM Student
WHERE
lastsignin>now()-interval '1 month'
and status = 1
GROUP BY floor( areaId / 10000) * 10000 ),
h as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as weekActiveAmount
FROM Student
WHERE
lastsignin>now()-interval '1 week'
and status = 1
GROUP BY floor( areaId / 10000) * 10000 ),
i as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as dayActiveAmount
FROM Student
WHERE
lastsignin>now()-interval '1 day'
and status = 1
GROUP BY floor( areaId / 10000) * 10000 ) ,
j as ( SELECT floor( c.areaId / 10000) * 10000 as tempAreaId ,
count( distinct c.uid ) as useAmount
FROM connectlog c inner join student s on c.uid=s.studentid
and
=#{startTime} and endTime<#{endTime} and s.status=1
]]>
GROUP BY floor( c.areaId / 10000) * 10000 ),
k as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as studentbytimeCount
FROM Student
where =#{startTime} and created<#{endTime}
]]>
and status=1
GROUP BY floor( areaId / 10000) * 10000 ) ,
l as ( SELECT floor( areaId / 10000) * 10000 as tempAreaId ,
count( studentId ) as studentLoginbytimeCount
FROM Student
where =#{startTime} and created<#{endTime}
and lastsignin>=#{startTime} and lastsignin<#{endTime}
]]>
and status=1
GROUP BY floor( areaId / 10000) * 10000 ),
m as(select floor( a.areaId / 10000) * 10000 as tempAreaId ,
count(a.uid) as renewCount
from
( select uid,count(uid) payCount,areaid from orderinfo o where created<#{startTime}
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as a
inner join
(select uid,count(uid) payCount,areaid from orderinfo o
where =#{startTime} and created<#{endTime}
]]>
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as b
on a.uid=b.uid
GROUP BY floor( a.areaId / 10000) * 10000)
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount ,
coalesce( f.takeAmount ,0 ) as takeAmount ,
case when coalesce( c.studentCount ,0 ) = 0 then 0.00
when coalesce( f.takeAmount ,0 ) = 0 then 0.00
else
round( (f.takeAmount * 100)::numeric / c.studentCount::numeric , 2 )
end as accountAmount ,
coalesce( g.activeAmount ,0 ) as activeAmount,
coalesce( h.weekActiveAmount ,0 ) as weekActiveAmount,
coalesce( i.dayActiveAmount ,0 ) as dayActiveAmount,
coalesce( j.useAmount ,0 ) as useAmount,
coalesce( k.studentbytimeCount ,0 ) as studentbytimeCount,
case when coalesce( k.studentbytimeCount ,0 ) = 0 then 0.00
when coalesce( l.studentLoginbytimeCount ,0 ) = 0 then 0.00 else
round( (l.studentLoginbytimeCount * 100)::numeric / k.studentbytimeCount::numeric , 2 )
end as accountAmountbyTime ,
coalesce(m.renewCount ,0 ) as renewCount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
LEFT JOIN f
ON a.areaId = f.tempAreaId
LEFT JOIN g
ON a.areaId = g.tempAreaId
LEFT JOIN h
ON a.areaId = h.tempAreaId
LEFT JOIN i
ON a.areaId = i.tempAreaId
LEFT JOIN j
ON a.areaId = j.tempAreaId
LEFT JOIN k
ON a.areaId = k.tempAreaId
LEFT JOIN l
ON a.areaId = l.tempAreaId
LEFT JOIN m
ON a.areaId = m.tempAreaId
ORDER BY a.areaId
with a as ( SELECT areaId , areaname FROM Area where parentId = #{areaId} ) ,
b as ( SELECT floor( areaId / 100) * 100 as tempAreaId ,
count( schoolId ) as schoolCount
FROM School
WHERE status = 1
AND floor( areaId / 10000) * 10000 = #{areaId}
GROUP BY floor( areaId / 100) * 100 ),
c as ( SELECT floor( areaId / 100) * 100 as tempAreaId ,
count( studentId ) as studentCount
FROM Student
WHERE floor( areaId / 10000) * 10000 = #{areaId} and status=1
GROUP BY floor( areaId / 100) * 100 ) ,
f as ( SELECT floor( M.areaId / 100) * 100 as tempAreaId ,
count( distinct M.studentId ) as takeAmount
FROM Student M
WHERE floor( M.areaId / 10000) * 10000 = #{areaId} and status=1
and M.lastsignin is not null
GROUP BY floor( M.areaId / 100) * 100 ) ,
g as ( SELECT floor( areaId / 100) * 100 as tempAreaId ,
count( studentId ) as activeAmount
FROM Student
WHERE floor( areaId / 10000) * 10000 = #{areaId}
AND
lastsignin>now()-interval '1 month'
and status=1
GROUP BY floor( areaId / 100) * 100 ),
h as ( SELECT floor( areaId / 100) * 100 as tempAreaId ,
count( studentId ) as weekActiveAmount
FROM Student
WHERE floor( areaId / 10000) * 10000 = #{areaId}
AND
lastsignin>now()-interval '1 week'
and status=1
GROUP BY floor( areaId / 100) * 100 ),
i as ( SELECT floor( areaId / 100) * 100 as tempAreaId ,
count( studentId ) as dayActiveAmount
FROM Student
WHERE floor( areaId / 10000) * 10000 = #{areaId}
AND
lastsignin>now()-interval '1 day'
and status=1
GROUP BY floor( areaId / 100) * 100 ),
j as ( SELECT floor( c.areaId / 100) * 100 as tempAreaId ,
count( distinct uid ) as useAmount
FROM connectlog c inner join student s on
c.uid=s.studentid and
floor( c.areaId / 10000) * 10000 = #{areaId}
AND
=#{startTime} and endTime<#{endTime}
]]>
and s.status=1
GROUP BY floor( c.areaId / 100) * 100 ),
k as ( SELECT floor( areaId / 100) * 100 as tempAreaId ,
count( studentId ) as studentbytimeCount
FROM Student
WHERE floor( areaId / 10000) * 10000 = #{areaId}
AND
=#{startTime} and created<#{endTime}
]]>
and status=1
GROUP BY floor( areaId / 100) * 100 ) ,
cn as ( select distinct uid from connectlog where =#{startTime} and starttime <#{endTime}
]]> and floor( areaId / 10000) * 10000 = #{areaId}
),
l as ( SELECT floor( areaId / 100) * 100 as tempAreaId ,
count( studentId ) as studentLoginbytimeCount
FROM cn inner join student on studentid=uid
WHERE floor( areaId / 10000) * 10000 = #{areaId}
AND
=#{startTime} and created<#{endTime}
]]>
and status=1
GROUP BY floor( areaId / 100) * 100 ),
m as(select floor( a.areaId / 100) * 100 as tempAreaId ,
count(a.uid) as renewCount
from
( select uid,count(uid) payCount,areaid from orderinfo o
where created<#{startTime}
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and floor( areaId / 10000) * 10000 = #{areaId}
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as a
inner join
(select uid,count(uid) payCount,areaid from orderinfo o
where =#{startTime} and created<#{endTime}
]]>
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and floor( areaId / 10000) * 10000 = #{areaId}
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as b
on a.uid=b.uid
GROUP BY floor( a.areaId / 100) * 100)
SELECT a.areaId as objectId , a.areaName as objectName,
coalesce( b.schoolCount ,0 ) as schoolCount ,
coalesce( b.schoolCount ,0 ) as numberCount ,
coalesce( c.studentCount ,0 ) as studentCount ,
coalesce( c.studentCount ,0 ) as payAmount ,
coalesce( f.takeAmount ,0 ) as takeAmount ,
case when coalesce( c.studentCount ,0 ) = 0 then 0.00
when coalesce( f.takeAmount ,0 ) = 0 then 0.00
else
round( (f.takeAmount * 100)::numeric / c.studentCount::numeric , 2 )
end as accountAmount ,
coalesce( g.activeAmount ,0 ) as activeAmount,
coalesce( h.weekActiveAmount ,0 ) as weekActiveAmount,
coalesce( i.dayActiveAmount ,0 ) as dayActiveAmount,
coalesce( j.useAmount ,0 ) as useAmount ,
coalesce( k.studentbytimeCount ,0 ) as studentbytimeCount ,
case when coalesce( k.studentbytimeCount ,0 ) = 0 then 0.00
when coalesce( l.studentLoginbytimeCount ,0 ) = 0 then 0.00
else
round( (l.studentLoginbytimeCount * 100)::numeric / k.studentbytimeCount::numeric , 2 )
end as accountAmountbyTime ,
coalesce(m.renewCount ,0 ) as renewCount
FROM a
LEFT JOIN b
ON a.areaId = b.tempAreaId
LEFT JOIN c
ON a.areaId = c.tempAreaId
LEFT JOIN f
ON a.areaId = f.tempAreaId
LEFT JOIN g
ON a.areaId = g.tempAreaId
LEFT JOIN h
ON a.areaId = h.tempAreaId
LEFT JOIN i
ON a.areaId = i.tempAreaId
LEFT JOIN j
ON a.areaId = j.tempAreaId
LEFT JOIN k
ON a.areaId = k.tempAreaId
LEFT JOIN l
ON a.areaId = l.tempAreaId
LEFT JOIN m
ON a.areaId = m.tempAreaId
ORDER BY a.areaId
with temp as(
select count(studentid) studentbytimecount,a.areaId from student st
inner join area a
on st.areaid=a.areaId
=#{startTime} and st.created<#{endTime}
]]>
and a.areaid > #{areaId} and a.areaid <#{areaId}+100 and st.areaid > #{areaId} and st.areaid <#{areaId}+100
and st.status=1
group by a.areaid
),
temp2 as(
select distinct(a.areaId) as objectId, a.areaName as objectName, count(distinct(s.schoolId)) as numberCount ,
count(distinct(ss.studentId)) as payAmount ,count(case when ss.endTime isnull then null else 1 end) as takeAmount ,
case when count(distinct(ss.studentId)) = 0 then 0.00 else
-- round(count(case when ss.endTime isnull then null else 1 end)*100::numeric/count(distinct(ss.studentId)::numeric),2) end as accountAmount ,
round(count(case when ss.lastsignin isnull then null else 1 end)*100::numeric/count(distinct(ss.studentId)::numeric),2) end as accountAmount ,
count(case when ss.lastsignin>now()-interval '1 month' then 1 else null end) as activeAmount,
count(case when ss.lastsignin>now()-interval '1 week' then 1 else null end) as weekActiveAmount,
count(case when ss.lastsignin>now()-interval '1 day' then 1 else null end) as dayActiveAmount,
from Area a
left join School s on s.areaId = a.areaId and s.status=1
left join (
select s.studentId,co.uid,sc.schoolId , s.lastsignin , max(co.endTime) as endTime from Student s
inner join StudentOwnClass so on so.studentId = s.studentId and so.status = 1 and s.status=1 and so.areaid > #{areaId} and so.areaid <#{areaId}+100 and s.areaid > #{areaId} and s.areaid <#{areaId}+100
inner join Classes c on c.classesId = so.classesId and c.classtype = 1 and c.status = 1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid and
a.areaid > #{areaId} and a.areaid <#{areaId}+100
left join connectlog co on co.uid = s.studentid and co.areaid > #{areaId} and co.areaid <#{areaId}+100
#{startTime}
]]>
group by s.studentId ,sc.schoolId, s.lastsignin,co.uid
) ss on ss.schoolId = s.schoolId
where a.parentid = #{areaId}
group by a.areaid
),
cn as ( select distinct uid from connectlog where
areaid > #{areaId} and areaid <#{areaId}+100
=#{startTime} and endtime <#{endTime}
]]>
),
temp3 as(select count(studentid) studentLoginbytimeCount,a.areaId from student st inner join cn on st.studentid=cn.uid
inner join area a
on st.areaid=a.areaId
=#{startTime} and st.created<#{endTime}
]]>
and st.areaid > #{areaId} and st.areaid <#{areaId}+100
and a.parentid = #{areaId}
and st.status=1
group by a.areaid),
temp4 as(select a.areaId,
count(a.uid) as renewCount
from
( select uid,count(uid) payCount,areaid from orderinfo o
where
(o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and created<#{startTime}
and floor( areaId / 100) * 100 = #{areaId}
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as a
inner join
(select uid,count(uid) payCount,areaid from orderinfo o
where
(o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
=#{startTime} and created<#{endTime}
]]>
and
areaId > #{areaId} and areaId <#{areaId}+100
and substring(to_char(uid, '9999999999999999') from 9 for 1 )='1'
group by uid,areaId) as b
on a.uid=b.uid
GROUP BY a.areaId ),
temp5 as(select areaId,count(schoolId) schoolCount from school where
areaId > #{areaId} and areaId <#{areaId}+100
=#{startTime} and created<#{endTime}
]]>
and status=1
GROUP BY areaId)
select objectId, objectName, numberCount , payAmount ,takeAmount ,coalesce( accountAmount ,0.00 ) accountAmount , activeAmount,
weekActiveAmount,dayActiveAmount,useAmount,coalesce( t.studentbytimecount ,0 ) as studentbytimecount ,
case when coalesce( t.studentbytimeCount ,0 ) = 0 then 0.00
when coalesce( t3.studentLoginbytimeCount ,0 ) = 0 then 0.00
else round( (t3.studentLoginbytimeCount * 100)::numeric / t.studentbytimeCount::numeric , 2 )
end as accountAmountbyTime,
coalesce( t4.renewCount ,0 ) renewCount,
coalesce( t5.schoolCount ,0 ) schoolCount
from temp2 t2 left join temp t on t.areaid=t2.objectId
left join temp3 t3 on t3.areaid=t2.objectId
left join temp4 t4 on t4.areaid=t2.objectId
left join temp5 t5 on t5.areaid=t2.objectId
order by objectId
limit #{pageSize} offset #{offset}
with temp as(
select count( distinct(sd.studentid)) studentbytimecount,sl.schoolId from studentownclass st
inner join classes c
on st.classesid=c.classesid and c.classtype=1 and c.status=1 and st.areaid=#{areaId}
inner join student sd on st.studentid=sd.studentid and sd.areaid=#{areaId}
=#{startTime} and sd.created<#{endTime} and sd.status=1
]]>
inner join school sl on sl.schoolid=c.schoolid
and sl.areaid = #{areaId}
group by sl.schoolId
),
temp2 as(
select distinct(s.schoolId) as objectId, s.schoolName as objectName, count(distinct(c.classesId)) as numberCount ,
count(distinct(ss.studentId)) as payAmount ,count(case when ss.endTime isnull then null else 1 end) as takeAmount ,
case when count(distinct(ss.studentId)) = 0 then 0.00 else
round(count(case when ss.lastsignin isnull then null else 1 end)*100::numeric/count(distinct(ss.studentId)::numeric),2) end as accountAmount,
count(case when ss.lastsignin>now()-interval '1 month' then 1 else null end) as activeAmount,
count(case when ss.lastsignin>now()-interval '1 week' then 1 else null end) as weekActiveAmount,
count(case when ss.lastsignin>now()-interval '1 day' then 1 else null end) as dayActiveAmount,
from School s
left join Classes c on c.schoolId = s.schoolId and s.status=1 and c.status=1 and c.classtype = 1
left join (
select s.studentId ,co.uid,c.classesId , s.lastsignin
,max(co.endTime) as endTime
from Student s
inner join StudentOwnClass so on so.studentId = s.studentId and so.status = 1 and s.status=1 and so.areaid=#{areaId} and s.areaid=#{areaId}
inner join Classes c on c.classesId = so.classesId and c.classtype = 1 and c.status = 1
inner join School sc on c.schoolId = sc.schoolId and sc.status=1
inner join Area a on a.areaId = sc.areaid and a.areaId= #{areaId}
left join connectlog co on co.uid = s.studentid and co.areaId=#{areaId}
#{startTime}
]]>
group by s.studentId ,c.classesId, s.lastsignin,co.uid
) ss on ss.classesId = c.classesId
where s.areaId = #{areaId} and s.status=1
group by s.schoolId
),
cn as ( select distinct uid from connectlog where areaid = #{areaId} and =#{startTime} and endtime <#{endTime}
]]>
),
temp3 as(
select count( distinct(sd.studentid)) studentLoginbytimeCount,sl.schoolId from studentownclass st
inner join classes c
on st.classesid=c.classesid and c.classtype=1 and c.status=1 and st.areaid=#{areaId}
inner join student sd on st.studentid=sd.studentid inner join cn on sd.studentid = cn.uid and sd.status=1 and sd.areaid=#{areaId}
=#{startTime} and sd.created<#{endTime}
]]>
inner join school sl on sl.schoolid=c.schoolid
and sl.areaid = #{areaId}
group by sl.schoolId
),
temp4 as(select a.schoolId,
count(a.uid) as renewCount
from
( select uid,count(uid) payCount,c.schoolId from orderinfo o
inner join studentownclass soc on soc.studentid=o.uid
and o.created<#{startTime} and soc.areaid = #{areaId}
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and o.areaId = #{areaId} and soc.status=1
inner join classes c on c.classesid=soc.classesid and c.classtype=1 and c.status=1
group by o.uid,c.schoolId ) as a
inner join
(select uid,count(uid) payCount,c.schoolId from orderinfo o
inner join studentownclass soc on soc.studentid=o.uid and soc.areaid = #{areaId}
and =#{startTime} and created<#{endTime}
]]>
and (o.isPayed = 1 or o.ispayed=-1) and (o.payWay > 0 or o.payway=-100)
and o.areaId = #{areaId} and soc.status=1
inner join classes c on c.classesid=soc.classesid and c.classtype=1 and c.status =1
group by o.uid,c.schoolId ) as b
on a.uid=b.uid
GROUP BY a.schoolId ),
temp5 as(select schoolId,count(classesId) classCount from classes where areaid=#{areaId}
and =#{startTime} and created<#{endTime}
]]> and classtype=1 and status=1 GROUP BY schoolId )
select objectId, objectName, numberCount , payAmount ,takeAmount ,coalesce( accountAmount ,0.00 ) accountAmount , activeAmount,
weekActiveAmount,dayActiveAmount,useAmount,coalesce( t.studentbytimecount ,0 ) as studentbytimecount,
case when coalesce( t.studentbytimeCount ,0 ) = 0 then 0.00
when coalesce( t3.studentLoginbytimeCount ,0 ) = 0 then 0.00
else round( (t3.studentLoginbytimeCount * 100)::numeric / t.studentbytimeCount::numeric , 2 )
end as accountAmountbyTime,
coalesce( t4.renewCount ,0 ) renewCount,
coalesce( t5.classCount ,0 ) classCount
from temp2 t2 left join temp t on t.schoolId=t2.objectId
left join temp3 t3 on t2.objectId=t3.schoolId
left join temp4 t4 on t2.objectId=t4.schoolId
left join temp5 t5 on t2.objectId=t5.schoolId
order by objectId
limit #{pageSize} offset #{offset}