• 欢迎光临~

# 为什么用了大牌工具后报表开发依然头痛

## 怎么办

### 集算器做数据准备写的快算的快

1 报表中需要呈现连续上涨超过 5 天的股票及上涨天数

``````select code,max(risenum)-1 maxRiseDays from
(  select code,count(1) risenum from
(
select code,changeSign,sum(changeSign) over(partition by code order by ddate) unRiseDays from
(
select
code,
ddate,
case when price>=lag(price) over(partition by code order by ddate)
then 0 else 1 end changeSign
from stock_record
)
)
group by code,unRiseDays
)
group by code
having max(risenum) > 5
``````

A
1=connect@l(“orcl”).query@x(“select * from stock_record order by ddate”)
2=A1.group(code)
3=A2.new(code,~.group@i(price < price[-1]).max(~.len())-1:maxrisedays)计算每只股票的连续上涨天数
4=A3.select(maxrisedays>=5)选出符合条件的记录

2 列出每一个用户最近一次登录间隔

SQL的大致写法

``````WITH TT AS
(SELECT RANK() OVER(PARTITION BY uid ORDER BY logtime DESC) rk, T.*  FROM t_loginT)
SELECT uid,(SELECT TT.logtime FROM TT where TT.uid=TTT.uid and TT.rk=1)
-(SELET TT.logtim FROM TT WHERE TT.uid=TTT.uid and TT.rk=2) interval
FROM t_loginTTTT GROUP BY uid
``````

A
2=A1.new(uid,#2(1).logtime-#2(2).logtime:interval)计算间隔

• 润乾报表官网
• 润乾报表下载