rushfee/resource/db/companycount_sql.xml

130 lines
4.1 KiB
XML
Raw Normal View History

2022-05-16 15:07:40 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqls SYSTEM "sql_definition.dtd">
<sqls>
<sql group="companycount">
<i id="count"><![CDATA[
select w.* ,w.jjdqyds+w.cqwsydl+w.cqwsqdse+w.cqwsldy +w.jjdqldy as 到期 from (
SELECT
nvl( b.org_short_name, '合计' ) 分公司 ,
count( 1 ) 总户数,
sum(
CASE
WHEN to_number(
trunc( SYSDATE ) - to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )) <= 180
and to_number(
trunc( SYSDATE ) - to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' ))>30
and t.count=0 THEN
1 ELSE 0 end ) cqwsydl,
sum(
CASE
WHEN to_number(
trunc( SYSDATE ) - to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )) <=30
and to_number(
trunc( SYSDATE ) - to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' ))>0
and t.count=0 THEN
1 ELSE 0 end ) cqwsldy,
sum(
CASE
WHEN to_number(
trunc( SYSDATE ) - to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )) <=30
and to_number(
trunc( SYSDATE ) - to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' ))>0
and t.count=0 and t.customerid in (select customer_id from rush_task_center ) THEN
1 ELSE 0 end ) rwzxsl,
sum(
CASE
WHEN to_number(
trunc( SYSDATE ) - to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )) <=365
and to_number(
trunc( SYSDATE ) - to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' ))>180 and t.count=0
THEN
1 ELSE 0 end ) cqwsqdse,
sum(
CASE
WHEN to_number(
trunc( SYSDATE ) - to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )) > 365 and t.count=0 THEN
1 ELSE 0 end ) ynys,
sum(
CASE
WHEN to_number(
trunc( SYSDATE ) - to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )) > 0 and t.count=0 THEN
1 ELSE 0 end ) qbcq,
sum(
CASE
WHEN
to_number( to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )-
trunc( SYSDATE ) ) >30 and
to_number( to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )-
trunc( SYSDATE ) ) <=90 and t.count=0 THEN
1 ELSE 0 end ) jjdqyds,
sum(
CASE
WHEN
to_number( to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )-
trunc( SYSDATE ) ) >0 and
to_number( to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )-
trunc( SYSDATE ) ) <=30 and t.count=0 THEN
1 ELSE 0 end ) jjdqldy,
sum(
CASE
WHEN
to_number( to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )-
trunc( SYSDATE ) ) >0 and
to_number( to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )-
trunc( SYSDATE ) ) <=30 and t.count=0 and t.customerid in (select customer_id from rush_task_center ) THEN
1 ELSE 0 end ) rwzxjjdqsl,
sum(
CASE
WHEN
to_number( to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )-
trunc( SYSDATE ) ) >90 and
to_number( to_date( substr( t.end_datechr, 0, 10 ), 'yyyy-MM-dd' )-
trunc( SYSDATE ) ) <=365 and t.count=0 THEN
1 ELSE 0 end ) jjdqsdse ,
sum( CASE WHEN count = 0 THEN 1 ELSE 0 END ) 未回访,
sum( CASE WHEN count = 1 THEN 1 ELSE 0 END ) 回访一次,
sum( CASE WHEN count = 2 THEN 1 ELSE 0 END ) 回访二次,
sum( CASE WHEN count = 3 THEN 1 ELSE 0 END ) 回访三次,
sum( CASE WHEN count = 4 THEN 1 ELSE 0 END ) 回访四次,
sum( CASE WHEN count = 5 THEN 1 ELSE 0 END ) 回访五次,
sum( CASE WHEN count = 6 THEN 1 ELSE 0 END ) 回访六次 ,
sum( CASE WHEN count = 7 THEN 1 ELSE 0 END ) 回访七次 ,
sum( CASE WHEN count = 8 THEN 1 ELSE 0 END ) 回访八次,
sum( CASE WHEN count = 9 THEN 1 ELSE 0 END ) 回访九次 ,
sum( CASE WHEN count = 10 THEN 1 ELSE 0 END ) 回访十次
from view_info t inner join company_organize b ON t.org_id = b.org_id
GROUP BY
rollup ( org_short_name)) w
]]></i>
<i id="usercount"><![CDATA[
select nvl(t.user_name,'合计') as 姓名 ,nvl(t.task_name,'剩余总量') 任务名称, count(1) as 剩余任务
from (select a.user_name,b.task_name,b.create_date from rush_task_center a left join
rush_task_list b on a.task_id =b.id )t
where $like(t.user_name,qn)
group by rollup ( t.user_name,t.task_name)
]]></i>
<i id="rushcount"><![CDATA[
select id,text from RUSH_DICTIONARY_COUNT
where codetype='rushcount' order by id
]]></i>
</sql>
</sqls>