lundi 6 novembre 2017

random row from diapason (1: n) in groups sql

I need select random row from Table using groups and order, but random's row number in group should not be more then constant (for example const = 3). What I mean: id time x 1 10:20 1 1 11:21 9 1 16:14 4 1 08:13 8 2 01:20 2 2 21:13 0

For id=1 rows could be: id time x 1 10:20 1 1 11:21 9 1 08:13 8 BUT not 1 16:14 4 because in order by time it's local number more than 3 for Id= 2 - any row




Aucun commentaire:

Enregistrer un commentaire