Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a TOP function or equivalent in Teradata?

Status
Not open for further replies.

bgruver

MIS
Oct 30, 2000
14
0
0
US
I'm pretty sure there is no "TOP" function, but was wondering if there is some easy way to do a TOP-like function. Any ideas?
 
bgruver,

Teradata has Rank function which will help u get the top n values. something like this

select
sub.city_desc,
sub.sales_value,
rank(sub.sales_value)
from
(
select
city_desc as city_desc,
sum(sales_value) as sales_value
from
city_sales
group by
city_desc
)as sub
qualify rank(sales_value) <= 5

the above sql will get u the top 5 cities based on sales value.

Regards,

Sridharan
 
I believe that you meant a function similar to the CEIL function in Oracle and opposite to the FLOOR function. The CEIL function provides the smallest integer that is >= to a specific value.

For instance,
CEIL(2) = 2
CEIL(1.3) = 2
CEIL(-2) = -2
CEIL(-2.3) = -2

Is this what you were looking for?

Doug Drake
(MOZC)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top