OCUP UML fundamental and ITIL foundation
To select a random record or records from MS Access, the method isn’t much different.
Instead of doing an ORDER BY NewID() like in SQL Server, you would use ORDER BY Rnd(Field1), where Field1 is the name of your primary auto-numbered key field.
Although the SQL statements are very similar, the results however, are not.
I ran the following SQL statement through my C# sharp code three times, each time looping to select 5000 random records. Each time however, the results were exactly the same.
I closed down the web app, and restarted it, and what do you know, the results were identical again.
OCUP UML fundamental and ITIL foundation
No.shukla raghav wrote:... the Rnd() expects an argument that is field name of the colums that is of type AutoNumber...
OCUP UML fundamental and ITIL foundation
shukla raghav wrote: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
.
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
OCUP UML fundamental and ITIL foundation
I don't think so.But i wanted to know cant we use group by clause in any way
OCUP UML fundamental and ITIL foundation
Consider Paul's rocket mass heater. |