数据自行模拟
说明:account_flow_id为唯一Id,Id为自增integer
SELECT a.company_id, a.create_time, a.balance,a.account_flow_id
FROM (SELECT company_id, max(id) id FROM tb_account_sub_flow WHERE create_time <'2019-05-13 23:59:59' GROUP BY company_id ) b
INNER JOIN tb_account_sub_flow a ON a.company_id = b.company_id AND a.id = b.id
ORDER BY a.company_id;