开发者

How do I limit the number of rows returned in a Netezza query?

开发者 https://www.devze.com 2022-12-23 06:23 出处:网络
I want to run a basic query, but return only the first ten rows of the table from Netezza select a.* from some_schema.some_table a

I want to run a basic query, but return only the first ten rows of the table from Netezza

select a.*
  from some_schema.some_table a
 where rownum < 10

What is the Netezza way of looking at jus开发者_开发技巧t those few rows?


Ah! Just found it.

For Netezza this query is

select a.*
  from some_schema.some_table a
 limit 10

-mcpeterson


SELECT * FROM schema_name..table_name LIMIT 100 OFFSET 50

LIMIT is number of records you need, and OFFSET is from where to count!


The below query should work for any random 'N' rows in a netezza table.

SELECT COLNAME1 FROM ( SELECT COLNAME1 FROM SCHEMANAME..TABLENAME ORDER BY COLNAME1 LIMIT n) A
MINUS
SELECT COLNAME1 FROM ( SELECT COLNAME1 FROM SCHEMANAME..TABLENAME ORDER BY COLNAME1 LIMIT m) B

Note : n>m ( m,n are integers )

0

精彩评论

暂无评论...
验证码 换一张
取 消