how to findout top four rows or last four rows in teradata?

Database
Enthusiast

how to findout top four rows or last four rows in teradata?

Hi guys,
we can do it the same in oracle using "top 4 " some thing like that?
how can do the same in teradata?

can any one pls help me regarding this?

regards,
bujji.
2 REPLIES
Enthusiast

Re: how to findout top four rows or last four rows in teradata?

You can use:
Select top 4 * from tablename;

But, I doubt, it will fetch you the top 4 rows from the database.
In Teradata, "top" works differently when compared to rownum in oracle.

Enthusiast

Re: how to findout top four rows or last four rows in teradata?

for top 4 rows..

u can use

select rank() order by ( column name) from table qualify rank <5

for last four rows..

select rank() order by ( column name) from table qualify rank <5 desc