Linked Questions
49 questions linked to/from How to select the nth row in a SQL database table?
20 votes
3 answers
14k views
Efficient data structure for a leaderboard, i.e., a list of records (name, points) - Efficient Search(name), Search(rank) and Update(points)
Please suggest a data structure for representing a list of records in memory. Each record is made up of: User Name Points Rank (based on Points) - optional field - can be either stored in the record ...
5 votes
6 answers
18k views
Get last item in a table - SQL
I have a History Table in SQL Server that basically tracks an item through a process. The item has some fixed fields that don't change throughout the process, but has a few other fields including ...
6 votes
3 answers
7k views
SQL Server, select a record every 'x' amount of records
Hi, I have “Table1” as shown above with some records on it and the column names are Id, Name and [Entry Date]. Column Id is primary key, I am using SQL Server 2005. I want to write a query that ...
4 votes
1 answer
15k views
Using rownum in oracle SQL statement in combination with order by clause
Which of the following two SQL statements will return the desired result set (i.e. the ten rows with Status=0 and the highest StartTimes)? Will both statements always return the same result set (...
4 votes
2 answers
5k views
How do I select every nth row?
My table has 81,225 rows. I am trying to select every 285th row: Select * From Test A Where ROWID > 0 AND ROWID <= 81225 AND ROWID % 285 = 285 % 285 This query returns 285 rows as expected, ...
1 vote
4 answers
8k views
3rd highest salary in oracle
I had been looking for the query to find the 3rd highest salary from the database (using Oracle database). I found the below query - SELECT * FROM ( SELECT e.*, row_number() over (order by sal DESC)...
0 votes
3 answers
2k views
How to select last row of mysql_query?
It is possible to select last row selected by mysql_query in php without iterating using mysql_fetch_row from first row till last? If so, what should I use?
1 vote
2 answers
4k views
Find nth ROW in SQLiteDatabase in android
How can i find nth ROW from SQLiteDatabase in android, i want something like this SELECT * FROM Student WHERE rownum = 2; Here rownum is not a part of Table in my DB looks like -------- Number --...
1 vote
2 answers
6k views
select nth row from a table sybase
I am using sybase database. I have to select every nth row from my table selfjoin(id,salary); I use select top 1 * from (select top 4 * from selfjoin order by id desc) order by id I get an error ...
1 vote
1 answer
4k views
Vb.net pull in a SQL table row by row
I am a little new to using vb.net and SQL so I figured I would check with you guys to see if what I am doing makes sense, or if there is a better way. For the first step I need to read in all the rows ...
1 vote
4 answers
3k views
find every 5th record from table
There are n record in a table ABC . write a query to select every 5th record from the table. for example there are 30 rows in a table. so query should output 5th,10th,15th,20th, 25th and 30th ...
2 votes
2 answers
905 views
Getting Next and Previous from MySQL When Dates Are the Same
Right now I have a problem because importing rows to my database from an external source happens so quickly. If more than one row is created with the exact same publish date, it is impossible to sort ...
0 votes
1 answer
2k views
How to Increment variable with button click , PHP\MySQL [duplicate]
Button to click <form action='' method='POST'> <input type='submit' name='submit' /> </form> Variable to be incremented on button click $currentid="1"; if(...
2 votes
1 answer
1k views
How can i get the nth row position from table without using limit?
How can i get the nth row position from table without using limit ? I have a table with four fields id,name,country,description. The query is returning by condition country = 'asia'. The total ...
1 vote
3 answers
671 views
Getting a specific number of rows from Database using RowNumber; Inconsistent results
Here is my SQL query: select * from TABLE T where ROWNUM<=100 If i execute this and then re-execute this, I don't get the same result. Why? Also, on a sybase system if i execute set rowcount 100 ...