开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜