Bookmark Topic Watch Topic
  • New Topic

Extracting random values

 
shukla raghav
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Report post to moderator
here is the problem

in my application i have a table that looks like the following


---------------------------------------------------------
RNO QID QDESC CHID
----------------------------------------------------------
1 A //some data// 1
2 B //some data// 2
3 C //some data// 1
4 D //some data// 2
5 E //some data// 1
6 F //some data// 3



now i need to randomly select exactly one record from each chapter, like my result set must look like this



---------------------------------------------
QID QDESC CHID
---------------------------------------------
A //some data// 1
B //some data// 2
F //some data// 3



you can see i am selecting one record from each chapter i.e. 1,2 and 3

beacuse i am connecting my application with an MS Access database here are some of the facts that i have already tested. May be they are useful.

in order to select N random values from a table in ms access we can use the following query



SELECT TOP N column
FROM table
ORDER BY Rnd(t1.RNO);



please suggest some solutions for how should i write the query. I have been trying hard bbut uselessly


 
Jan Cumps
Bartender
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please keep using your original post. People can see what you have tried already.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Agreed - closing this copy.
 
    Bookmark Topic Watch Topic
  • New Topic