I have 400K records on my table. Now I wanted you pull out random records that falls every 79th records from top to bottom. How can you do that on sql?
Your help is much appreciated.
thanks,
DM
8 2775
yes .. try this
$sql = "select * from table_name order by RAND() limit 79 "
just a clarification i wanted to select the records on my table that has 437K row any records that falls on every 79th records. To sum up i should get aroun 5,500 number of records filtering it from top to bottom.
im using ms sql server and i had error
SQL
select * FROM employee with(nolock) order by RAND() limit 79
Error Msg - Msg 102, Level 15, State 1, Line 1
-
Incorrect syntax near 'limit'.
-
try with out "with (NOLOCK)"
and that gonna wrk
select * FROM employee order by RAND() limit 79
Moved to SQL Server forum.
prabirchoudhury, it's still not working same error of
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'limit'.
Use ROW_NUMBER() function as inside a subquery and put a WHERE on the outer query where RownumberReturned mod 79 = 0
That's a pseudo-code.
Happy Coding!
--- CK
@ck9663
im having syntax error on below sql query
Msg 207, Level 16, State 1, Line 4
Invalid column name 'RowNumber'.
Msg 207, Level 16, State 1, Line 4
Invalid column name 'RowNumber'.
- SELECT *,
-
ROW_NUMBER() OVER (ORDER BY RAND()) AS 'RowNumber'
-
FROM users with (nolock)
-
where RowNumber between 79 and 0
Use it as a subquery instead.
Happy Coding!!!
--- CK
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jayson_13 |
last post by:
Hi,
I need to implement a counter and i face problem of locking so hope
that u guys can help me.
I try to do test like this :
1st connection
SELECT * FROM nextkey WHERE tblname = 'PLCN'...
|
by: Daniel Tan |
last post by:
Hi, how can i select every record from a subform that matched to my
searching criteria ? i tried to use SQL select and "= '" &
forms!xxx!xxx.form!field & '"" but it will only select first record...
|
by: Jason Kumpf |
last post by:
OK I've been staring at this code all day and still with everything I
have tried I cannot figure out two problems I am having. Once is why
the space limit for the directory I create in the code...
|
by: Peter Proost |
last post by:
Hi, I'm creating an import module to read data from old textfiles, run some
calculations on them and save them to sql server. I've figured out how to do
a select on textfile using a schema.ini file...
|
by: Grant McLean |
last post by:
Hi
First a simple question ...
I have a table "access_log" that has foreign keys "app_id" and
"app_user_id" that reference the "application_type" and "app_user"
tables. When I insert into...
|
by: ja |
last post by:
Hello all,
How can I ramdomly select a list of records from an existing table?
For example: 500,000 names divided by 20,000 samples = 25. The N is
25, meaning samples would be sent to every...
|
by: Jimmy |
last post by:
thanks to everyone that helped, unfortunately the code samples people gave me don't work. here is what i have so far:
<%
Dim oConn, oRS, randNum
Randomize()
randNum = (CInt(1000 * Rnd) + 1) *...
|
by: Matthew Wells |
last post by:
I have a listbox set to simple multi select. For this example, users only
select one item at a time. I have command buttons on the form for First,
Previous, Next, Last, New (record). The form...
|
by: ddtpmyra |
last post by:
I have 400K records on my Access database. Now I wanted you pull out randomly records that falls on 79th records from top to bottom. How can you do that on sql?
Your help is much appreciated....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |