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

 

 

相关文章:

  • 2021-09-10
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-26
  • 2021-11-28
  • 2021-11-02
  • 2022-12-23
  • 2021-07-15
  • 2021-10-14
相关资源
相似解决方案