窗口函数,根据 账户开窗口 随机取 3个数据
SELECT
*
FROM
( SELECT row_number() over ( PARTITION BY account ORDER BY rand()) AS rownum, id, account, amount FROM t_order ) t
WHERE
t.rownum <= 3
SELECT
*
FROM
( SELECT row_number() over ( PARTITION BY account ORDER BY rand()) AS rownum, id, account, amount FROM t_order ) t
WHERE
t.rownum <= 3