窗口函數(shù),根據(jù) 賬戶開(kāi)窗口 隨機(jī)取 3個(gè)數(shù)據(jù)
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