vendredi 5 août 2016

MS Access select distinct random values

How can I select 4 distinct random values from the field answer in MS Access table question?

SELECT TOP 4 answer,ID FROM question GROUP BY answer ORDER BY rnd(INT(NOW*ID)-NOW*ID)

Gives error message:

Run-time error '3122': Your query does not include the specified expression 'ID' as part of an aggregate function.

SELECT DISTINCT TOP 4 answer,ID FROM question ORDER BY rnd(INT(NOW*ID)-NOW*ID)

Gives error message:

Run-time error '3093': ORDER BY clause (rnd(INT(NOWID)-NOWID)) conflicts with DISTINCT.




Aucun commentaire:

Enregistrer un commentaire