6

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 just those few rows?

Joshua Schlichting
  • 3,110
  • 6
  • 28
  • 54
mcpeterson
  • 4,894
  • 4
  • 24
  • 24
  • 5
    It's not really the "First ten rows of the table", it's just SOME 10 rows from the table. First implies order. Without Order By tables have no order. – Stephanie Page May 26 '10 at 16:51

3 Answers3

7

Ah! Just found it.

For Netezza this query is

select a.*
  from some_schema.some_table a
 limit 10

-mcpeterson

DineshDB
  • 5,998
  • 7
  • 33
  • 49
mcpeterson
  • 4,894
  • 4
  • 24
  • 24
4
SELECT * FROM schema_name..table_name LIMIT 100 OFFSET 50

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

Logan Wayne
  • 6,001
  • 16
  • 31
  • 49
2

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 )

Brandon
  • 68,708
  • 30
  • 194
  • 223
Teja
  • 13,214
  • 36
  • 93
  • 155