我正在使用MySQL。
我有一个$orderbook = $exchange->fetch_order_book ($exchange->symbols[0]);
$bid = count ($orderbook['bids']) ? $orderbook['bids'][0][0] : null;
$ask = count ($orderbook['asks']) ? $orderbook['asks'][0][0] : null;
$spread = ($bid && $ask) ? $ask - $bid : null;
$result = array ('bid' => $bid, 'ask' => $ask, 'spread' => $spread);
var_dump ($exchange->id, 'market price', $result);
语句工作正常。
但是,当我使用相同的SELECT
语句尝试CREATE TABLE ... SELECT...
语句时,出现错误。
SELECT
在第1行被注释掉的情况下,CREATE TABLE db.daily_group_summary
SELECT
MAX(STR_TO_DATE(REPLACE(t_stamp, '-', ','),'%Y,%m,%d %H:%i')) AS t_stamp
(MAX(Total_filtrate_volume)) AS volume
FROM db.group_table
GROUP BY DAY(t_stamp)
ORDER BY t_stamp ASC;
产生了预期的结果。
包括第1行在内,我收到错误消息:
错误代码:1292。错误的日期时间值被截断:'2018,11,26 14:52:36'
我在做什么错了?
答案 0 :(得分:0)
CREATE TABLE db.daily_group_summary as (SELECT MAX(STR_TO_DATE(REPLACE(t_stamp, '-', ','),'%Y,%m,%d %H:%i')) AS t_stamp, (MAX(Total_filtrate_volume)) AS volume
FROM db.group_table
GROUP BY DAY(t_stamp)
ORDER BY t_stamp ASC);