[Solved] First 5 entries for a single user
Try this query: SELECT cust_id, date FROM ( SELECT cust_id, date, row_number() OVER (partition by cust_id ORDER BY date, id ) rn FROM Transaction ) as alias WHERE rn <= 5 ORDER BY 1,2 demo: http://sqlfiddle.com/#!15/cfd2e/4 2 solved First 5 entries for a single user