select
old.now_time,
round(
( new.count - old.count )
/ old.count *
100,2)
, new.count ncount,
old.count ocount
from (
select
sum( if ( b.count >1,
1,1)
) count,
b.now_time,
b.tenant_code
from
( select
date_format( ro.create_dt,
'%y-%m'
) as now_time,
a.tenant_code,
a.order_no,
count( a.
id) count
from
t_rep_order_timeout a
inner join t_rep_order ro on
a.tenant_code = ro.tenant_code and a.order_no = ro.order_no
where
a.tenant_code =
'zlyy'
group by
date_format( ro.create_dt,
'%y-%m'),
a.tenant_code,
a.order_no
) b
group by
b.now_time,
b.tenant_code
) new
left join
(select
sum( if ( b.count >1,
1,1)
) count,
b.now_time,
b.tenant_code
from
( select
date_format( date_add( ro.create_dt, interval 1 year )
,'%y-%m'
) as now_time,
a.tenant_code,
a.order_no,
count( a.
id) count
from
t_rep_order_timeout a
inner join t_rep_order ro on
a.tenant_code = ro.tenant_code and a.order_no = ro.order_no
where
a.tenant_code =
'zlyy'
group by
date_format( date_add( ro.create_dt, interval 1 year )
,'%y-%m'),
a.tenant_code,
a.order_no
) b
group by
b.now_time,
b.tenant_code) old
on old.tenant_code = new.tenant_code and old.now_time = new.now_time
select
old.now_time,
round(
( new.count - old.count )
/ old.count *
100,2)
, new.count ncount,
old.count ocount
from (
select
sum( if ( b.count >1,
1,1)
) count,
b.now_time,
b.tenant_code
from
( select
date_format( ro.create_dt,
'%y-%m'
) as now_time,
a.tenant_code,
a.order_no,
count( a.
id) count
from
t_rep_order_timeout a
inner join t_rep_order ro on
a.tenant_code = ro.tenant_code and a.order_no = ro.order_no
where
a.tenant_code =
'zlyy'
group by
date_format( ro.create_dt,
'%y-%m'),
a.tenant_code,
a.order_no
) b
group by
b.now_time,
b.tenant_code
) new
left join
(select
sum( if ( b.count >1,
1,1)
) count,
b.now_time,
b.tenant_code
from
( select
date_format( date_add( ro.create_dt, interval 1 month )
,'%y-%m'
) as now_time,
a.tenant_code,
a.order_no,
count( a.
id) count
from
t_rep_order_timeout a
inner join t_rep_order ro on
a.tenant_code = ro.tenant_code and a.order_no = ro.order_no
where
a.tenant_code =
'zlyy'
group by
date_format( date_add( ro.create_dt, interval 1 month )
,'%y-%m'),
a.tenant_code,
a.order_no
) b
group by
b.now_time,
b.tenant_code) old
on old.tenant_code = new.tenant_code and old.now_time = new.now_time
select
case
when
length( mon )
=1 then
concat(
'2019-0'
, mon ) else concat(
'2019-'
, mon )
end months
from
( select @m :
= @m +
1 mon from t_rep_order_timeout,
( select @m :=0
) a ) aa
limit 12
此處所用的輔助表t_rep_oder_timeot表資料必須超過12條
希望本文對你有所幫助~~如果對介面測試、自動化測試、面試經驗交流感興趣可以加入我們。642830685,免費領取最新軟體測試大廠面試資料和python自動化、介面、框架搭建學習資料!技術大牛解惑答疑,同行一起交流。
做acm用到的幾個C 庫函式
在做acm時往往利用庫函式可以既方便又高效的解決一些問題,下面就記錄下最近用到的庫函式來幫助自己熟悉stl,不定期跟新。1.sort 函式 stl自帶的排序函式,使用標頭檔案的 include 在排序問題中使用此函式可以省去很多精力。int main 此例中sort函式有兩個引數,第乙個是指向序列頭...
sql 統計常用的sql
統計常用的sql 統計常用的sql語句 今天的所有資料 select from 表名 where datediff dd,datetime型別字段,getdate 0昨天的所有資料 select from 表名 where datediff dd,datetime型別字段,getdate 17天內的...
幾個常用的SQL
一 刪列 alter table 表名 drop column column b hana中 alter table 表名 drop 欄位名 二 增列 alter table 表名 add 列名 varchar 20 hana中 alter table schema1 table1 add crea...