系统设计要求,业务逻辑与数据存储分离
数据分散在不同的数据源中
计算逻辑复杂,SQL实现困难
汇总每个人的值班天数
A | |
---|---|
1 | =file(“/Users/test/duty.xlsx”).importxls@tx() |
2 | =A1.groups(name;count(name):count) |
获取每个月、每个人、头三天的加班记录
A | |
---|---|
1 | =file(“/Users/test/duty.xlsx”).importxls@tx() |
2 | =A1.groups(month(workday):mon,name;~.top(3):top3) |
按顺序分别列出使用 Chinese、English、French 作为官方语言的国家数量
A | |
---|---|
1 | =connect(“mysql”) |
2 | =A1.query@x(“select * from world.countrylanguage where isofficial=‘T’”) |
3 | [Chinese,English,French] |
4 | =A2.align@a(A3,Language) |
5 | =A4.new(A3(#):name,~.len():cnt) |
select max(continuousDays)-1 from (select count(*) continuousDays from (select sum(changeSign) over(order by tradeDate) unRiseDays from (select tradeDate, case when closePrice>lag(closePrice) over(order by tradeDate) then 0 else 1 end changeSign from stock) ) group by unRiseDays)
A | |
---|---|
1 | =stock.sort(tradeDate) |
2 | =0 |
3 | =A1.max(A2=if(closePrice>closePrice[-1],A2+1,0)) |
其实这个计算很简单,按照自然思维:先按交易日排序(行1),然后比较当天收盘价比前一天高就+1,否则就清零,最后求个最大值(行3)