SELECT bu.id, bu.bind_user_time AS brokerageTime,
(SELECT SUM(price) FROM trade_brokerage_record r
WHERE r.user_id = bu.id AND biz_type = #{bizType} AND r.status = #{status} AND r.deleted = FALSE) AS brokeragePrice,
(SELECT COUNT(1) FROM trade_brokerage_record r
WHERE r.user_id = bu.id AND biz_type = #{bizType} AND r.status = #{status} AND r.deleted = FALSE) AS brokerageOrderCount,
(SELECT COUNT(1) FROM trade_brokerage_user c
WHERE c.bind_user_id = bu.id AND c.deleted = FALSE) AS brokerageUserCount
FROM trade_brokerage_user AS bu
bu.deleted = false
and bu.bind_user_id in
#{bindUserId}
ORDER BY brokerageUserCount ${sortingField.order}
ORDER BY brokerageOrderCount ${sortingField.order}
ORDER BY brokeragePrice ${sortingField.order}
ORDER BY bu.bind_user_time DESC