3
I would like some SQL command for a MS-Access database where I have 500 records and only to return 20 records so random being these (10 FEMININE and 10 MALE) and sorted in alphabetical order by name.
The structure of the table
tbLista
is quite simple...
ID - Long (500 registros) NOME - Texto SEXO - Texto (FEMININO/MASCULINO)
This code is what I have, but returns only the records randomly...
SELECT TOP 20 tbNew.ID, tbNew.NOME, tbNew.SEXO FROM ( SELECT tbLista.ID, tbLista.NOME, tbLista.SEXO FROM tbLista ORDER BY Rnd(Len(ID)) ) AS tbNew;
Thank you for your attention...
I’d like to share the code you’ve tried to make?
– StatelessDev
@Statelessdev - I’ve already managed to run random SQL code, but unsuccessfully filtering by genre...
SELECT TOP 20 tbNew.ID, tbNew.NOME, tbNew.SEXO
FROM (SELECT tbLista.ID, tbLista.NOME, tbLista.SEXO FROM tbLista ORDER BY Rnd(Len(ID))) AS tbNew;
– Maux
Edit your question and add that code there. It’s easier for people to view and help you ;)
– StatelessDev
@Statelessdev - OK!
– Maux