Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netezza Limit clause with order by

Tags:

netezza

In Netezza, if I do:

SELECT 
   *
FROM Tbl order by col1 
LIMIT 10 OFFSET 20;

First of all, what is OFFSET 20. And also, will this give me the first 10 rows specified in the order by or will the order by apply after random 10 rows are selected? I wish to select the first 10 rows of the table as specified in my order by.

like image 465
Victor Avatar asked Jan 29 '14 15:01

Victor


People also ask

How do I limit the number of rows in Netezza?

Netezza User rowset Limit Syntax You can specify a Netezza user rowset limit when you create a user or group in Netezza performance server. ALTER command can also be used to limit the rowset of a user or a group which are already available in the Netezza server. You can specify any number up to 2,147,483,647 or zero.

What is the use of limit clause with select query?

The LIMIT clause can restrict the result set of the query to some maximum number of rows. If this clause specifies a value smaller than the number of qualifying rows, the query returns only a subset of the rows that satisfy the selection criteria.

Which clause limits the returned data to a row count?

In the SELECT argument, the LIMIT clause is used to LIMIT the number of rows to be returned.

What is limit clause SQL?

The LIMIT clause is used to specify the number of records to return. The LIMIT clause is useful on large tables with thousands of records. Returning a large number of records can impact performance.


1 Answers

If your table col1 was a list from 1 to 1000

Limit 10 would return 1-10

Limit 10 OFFSET 20 would return 21-31

Remove the Offset to get just the first 10 rows and yes it will process the order by first.

like image 180
Niederee Avatar answered Sep 22 '22 09:09

Niederee