I have a product table like this:
Product name , Affiliate ID , ProductCode
a, 1, 1
b, 1, 2
c, 1, 3
d, 1, 5
e, 1, 7
f, 2, 4
g, 2, 6
I want to return first four products from each Affiliate ID. The 'ProductCode' column signifies the order in which the products were added, so can I use this column to sort my results. But I don't know how to return the first four results from each Affiliate ID? If I use the 'group' function it returns only one row of each affiliate ID.