sqlalchemy presto 时间比较

时间:2018-07-27 10:45:37   收藏:0   阅读:2309

大数据统计时,需要计算开仓订单减掉经纪商时间差,等于n 小时 或 星期几的订单。

presto sql语句如下:

select sum(profit) from t_table where open_time > 1970-01-01 00:00:00.0 
and open_time < 2018-06-02 00:24:18.0 and hour(date_parse(open_time,%Y-%m-%d %H:%i:%S.%f))  - 6 = 21;


 

select sum(profit) from t_table where open_time > 1970-01-01 00:00:00.0 
and open_time < 2018-06-02 00:24:18.0 and dow(date_parse(open_time,%Y-%m-%d %H:%i:%S.%f))  - 6 = 2;

 

sqlalchemy filter条件写法:

filter(extract(hour, cast(t_table.open_time,TIMESTAMP)) - 6 == 21)

--week

filter(extract(dow, cast(cast(t_table.open_time, TIMESTAMP) - text("interval 6 hour"),TIMESTAMP))  == 2)

 

and  [?nd; (?)n; ?nd]  详细X
基本翻译
conj. 和,与;就;而且;但是;然后
n. (And)人名;(土、瑞典)安德
网络释义
and:
and how: 的确
Yuan and: 元和

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!