系统设计要求,业务逻辑与数据存储分离
数据分散在不同的数据源中
计算逻辑复杂,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)