交易客户总数
/dbs/api/tradingStores/count?merchantCode=800202&start=2018-01-01&end=2018-04-01&isCooperate=1&newOrOld=1
select decode(count(distinct t1.customercode),null,0,count(distinct t1.customercode)) from bi_trading_store t1
inner join (select customercode,sum(orderquantity) orderqty from bi_order_condition where orderstatus=40
and merchantcode='800202'
group by customercode) t2 on t1.customercode=t2.customercode
where t2.orderqty=1
and t1.statisticstime>='2018-01-01' and t1.statisticstime<='2018-04-01'
and t1.merchantcode='800202'
and t1.iscooperate=1
期间新增交易客户数
/dbs/api/tradingStores/added?merchantCode=800202&start=2018-01-01&end=2018-04-01
select decode(count(distinct customercode),null,0,count(distinct customercode)) from bi_trading_store
where merchantcode='800202' and statisticstime>='2018-01-01' and statisticstime<='2018-04-01'
and customercode not in
(select distinct customercode from bi_trading_store
where merchantcode='800202' and statisticstime<'2018-01-01')
每月交易客户数
/dbs/api/tradingStores/countByMonth?merchantCode=800202&start=2018-01-01&end=2018-04-01&isCooperate=1
select t1.monthlist,decode(t2.tradingstoreqty,null,0,t2.tradingstoreqty) from
(SELECT TO_CHAR(ADD_MONTHS(TO_DATE('2018-01', 'yyyy-MM'), ROWNUM - 1),'yyyy-MM') as monthlist FROM DUAL
CONNECT BY ROWNUM <= months_between(to_date('2018-04', 'yyyy-MM'),to_date('2018-01', 'yyyy-MM')) + 1) t1
left join
(select substr(statisticstime,0,7) statisticstime,count(distinct customercode) tradingstoreqty
from bi_trading_store
where substr(statisticstime,0,7)>='2018-01' and substr(statisticstime,0,7)<='2018-04'
and merchantcode='800202' and iscooperate=2
group by substr(statisticstime,0,7))t2 on t1.monthlist=t2.statisticstime order by t1.monthlist
每天交易客户数
/dbs/api/tradingStores/countByDay?merchantCode=800202&start=2018-01-01&end=2018-04-01&isCooperate=1
select t1.daylist,decode(t2.tradingstoreqty,null,0,t2.tradingstoreqty) from
(SELECT TO_CHAR(TO_DATE('2018-01-01', 'yyyy-MM-dd') + ROWNUM - 1,'yyyy-MM-dd') as daylist FROM DUAL
CONNECT BY ROWNUM <= trunc(to_date('2018-04-01', 'yyyy-MM-dd') - to_date('2018-01-01', 'yyyy-MM-dd')) + 1) t1
left join
(select statisticstime,count(distinct customercode) tradingstoreqty from bi_trading_store
where statisticstime>='2018-01-01' and statisticstime<='2018-04-01'
and merchantcode='800202' and iscooperate=2
group by statisticstime)t2 on t1.daylist=t2.statisticstime order by t1.daylist