SELECT size,instrument_id,
(CASE side
WHEN "sell" THEN
group_concat(id ORDER BY id)
END )as sell_ids,
(CASE side
WHEN "buy" THEN
group_concat(id ORDER BY id)
END) as buy_ids
FROM `okex_spot_orders` WHERE `okex_spot_orders`.`deleted_at` IS NULL GROUP BY size,instrument_id
SELECT size,instrument_id,group_concat(CASE side
WHEN "sell" THEN
id
END ) as sell_ids,
group_concat(CASE side
WHEN "buy" THEN
id
END ) as buy_ids
FROM `okex_spot_orders` WHERE `okex_spot_orders`.`deleted_at` IS NULL GROUP BY size,instrument_id
两条sql语句看起来查询的结果都是正确的,但是第一条查询出来的结果却是错误的,并且第一条语句5.7及以上版本还需要设置sql_model 去除
only_full_group_by。而第二条却不用.
至于为什么第一条查询出来的数据是错的,本人暂时也不清楚。