crystalball
New Member
- Joined
- Aug 15, 2011
- Messages
- 11
Hello,
I'm attempting to pull a random sample of 5 rows from a chunk of data I'll be pulling in a query. While I'm able to get the data into excel, and it does select 5 entries to display, my Order By entry fails to randomize in excel (it works perfectly when run as a query in access). Do any of you excel gurus know why ordering by random(Autonumbered field) would fail here (the query does run, it just doesn't work properly. Same 5 every time). Do you know of another way to command it to randomize if this method can't be fixed?
I know I could probably do this with some MacGuyvering in excel (select all entries with those criteria, assign random numbers in excel, use those numbers to figure out which 5 to pick) but I'd prefer to get it done in query form if possible so it can be reused in other areas.
Any help appreciated.
I'm attempting to pull a random sample of 5 rows from a chunk of data I'll be pulling in a query. While I'm able to get the data into excel, and it does select 5 entries to display, my Order By entry fails to randomize in excel (it works perfectly when run as a query in access). Do any of you excel gurus know why ordering by random(Autonumbered field) would fail here (the query does run, it just doesn't work properly. Same 5 every time). Do you know of another way to command it to randomize if this method can't be fixed?
SELECT top 5 DB.Test
FROM `C:\Users\...\DB.accdb`.DB DB
WHERE (DB.Position1=?) AND (DB.Position2=?)
ORDER BY RND(DB.ID);
I know I could probably do this with some MacGuyvering in excel (select all entries with those criteria, assign random numbers in excel, use those numbers to figure out which 5 to pick) but I'd prefer to get it done in query form if possible so it can be reused in other areas.
Any help appreciated.