I have 10 different stores, each of which has a number of products.
Product(product_id, store_id, name, …)
A simple select returns the list of products in order of store_id (as this is they way they are inserted). However what I want is a list of products that are distributed evenly across each store.
At the moment the result set looks like:
Store 1 - Product 1
Store 1 - product 2
Store 2 - product 1
Store 2 - product 2
Store 2 - product 3
Store 3 - product 1
But I want something like:
Store 3 - Product 1
Store 1 - Product 2
Store 2 - Product 3
Store 1 - Product 1
Store 3 - Product 2
It by no means has to be perfect, I just want some sort of even spread of products from different stores, so those from the same store are not clumped together.
I have no other column I can order by to give the desired effect and the only other solution I can think of is asigning random numbers to records and using this.