473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Select every 79th record

ddtpmyra
333 100+
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
May 15 '09 #1
8 2775
prabirchoudhury
162 100+
yes .. try this

$sql = "select * from table_name order by RAND() limit 79 "
May 15 '09 #2
ddtpmyra
333 100+
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
Expand|Select|Wrap|Line Numbers
  1. Msg 102, Level 15, State 1, Line 1
  2. Incorrect syntax near 'limit'.
  3.  
May 15 '09 #3
prabirchoudhury
162 100+
try with out "with (NOLOCK)"

and that gonna wrk

select * FROM employee order by RAND() limit 79
May 16 '09 #4
mwasif
802 Expert 512MB
Moved to SQL Server forum.
May 16 '09 #5
ddtpmyra
333 100+
prabirchoudhury, it's still not working same error of
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'limit'.
May 18 '09 #6
ck9663
2,878 Expert 2GB
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
May 18 '09 #7
ddtpmyra
333 100+
@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'.
Expand|Select|Wrap|Line Numbers
  1. SELECT *,
  2.     ROW_NUMBER() OVER (ORDER BY RAND()) AS 'RowNumber'
  3.     FROM users with (nolock)
  4.     where RowNumber between  79 and 0
Sep 8 '09 #8
ck9663
2,878 Expert 2GB
Use it as a subquery instead.

Happy Coding!!!

--- CK
Sep 10 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
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'...
4
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...
4
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...
7
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...
1
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...
4
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...
48
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) *...
5
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...
7
ddtpmyra
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....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.