首页 > 数据库技术 > 详细

sqlalchemy presto 时间比较

时间:2018-07-27 10:36:40      阅读:669      评论:0      收藏:0      [点我收藏+]

大数据统计时,需要计算开仓订单减掉经纪商时间差,等于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: 元和

sqlalchemy presto 时间比较

原文:https://www.cnblogs.com/fithon/p/9375991.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!