Return 10 rows per person from Access table -


i have table includes id, person's name, , other data. i'm trying write query returns 10 rows each person (ideally 10 random rows, if has first 10 rows each person, suffice). i've found sql return 10 random rows table, not 10 rows per person. tells how solve in oracle, i'm having trouble making work in access: sql return n rows per row value

select  *    (         select  row_number() on (partition birthcountry                                     order dbms_random.value) rn         ,       firstname         ,       lastname         ,       birthdate         ,       birthcountry            yourtable         )   rn <= 10 

edit: have tried based on link posted comments, , returns 1 record (for person has 1 record in table--all others have more 10).

select a.id, a.mapped_prov_name, count(*) rank_number qryjustnames inner join qryjustnames b on a.mapped_prov_name = b.mapped_prov_name group a.id, a.mapped_prov_name having count(*) <= 10 order a.mapped_prov_name 

the following code returns 10 random rows of data each name can find.

select yt.id, yt.name, yt.data yourtable yt id in ( select top 10 id yourtable name = yt.name order rnd(yt.id) ) order id, name 

i've found answer here: ms access select top n query grouped multiple fields modified needs.

kind regards,

wouter


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -