java where in大量数据_java 统计大量数据:

SELECTCITYCODE,ZONE,SUM(LIVELYUSERS)ASLIVELYUSERS,SUM(RENZHENGUSERS)ASRENZHENGUSERS,SUM(DULIUSERS)ASDULIUSERSFROM(SELECTCASEWHENT.CITYCODEISNULLANDT.ADSLACCISNOTNULLTHEN'...

SELECT CITYCODE,ZONE,SUM(LIVELYUSERS) AS LIVELYUSERS,SUM(RENZHENGUSERS) AS RENZHENGUSERS,

SUM(DULIUSERS) AS DULIUSERS

FROM(

SELECT CASE

WHEN T.CITYCODE IS NULL AND T.ADSLACC IS NOT NULL THEN

'其他(未知地市)'

WHEN T.CITYCODE IS NULL AND T.ADSLACC IS NULL THEN

'未认证'

ELSE

S.CITIESNAME

END AS ZONE,

T.CITYCODE,

COUNT(T.MUSERID) AS LIVELYUSERS,

COUNT(CASE WHEN T.ADSLACC IS NOT NULL THEN T.ADSLACC END) AS RENZHENGUSERS,

COUNT(DISTINCT CASE WHEN T.ADSLACC IS NOT NULL THEN T.ADSLACC END) AS DULIUSERS

FROM TBL_USERINFO_JX T

LEFT JOIN SERCITIESINFOTABLE S ON T.CITYCODE = S.CITIESID

INNER JOIN (SELECT *

FROM (SELECT T1.YUSERID,

T1.FDATE,

T1.MUSERID,

ROW_NUMBER() OVER(PARTITION BY T1.MUSERID ORDER BY T1.FDATE DESC) RN

FROM TBL_GETUSERINFO_JX T1

WHERE SUBSTR(T1.CHANNEL,

INSTR(T1.CHANNEL, '-') + 1,

INSTR(T1.CHANNEL, '-') - 2) = '15' and TO_CHAR(T1.FDATE,'YYYY-MM-DD')>='2012-01-30' AND TO_CHAR(T1.FDATE,'YYYY-MM-DD')<='2012-02-01')

WHERE RN = 1) T2 ON T.MUSERID=T2.MUSERID

GROUP BY T.CITYCODE,S.CITIESNAME,T.ADSLACC) GROUP BY ZONE,CITYCODE ORDER BY CITYCODE ASC;

谁能帮忙优化下这sql,统计上10w条记录,速度非常慢,

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值