Archives of the TeradataForum
Message Posted: Fri, 21 May 2004 @ 09:45:50 GMT
Subj: | | Re: Select TOP 10 * .. |
|
From: | | McCall, Glenn D |
Have you tried csum (or rank) and qualify
select *
from some_table
qualify csum (1, sort_key_1, sort_key_2) <= 10;
csum might be better to use because it will generate unique numbers. Rank will return duplicate values if it encounters duplicate sort
key values. For example
SK1 SK2 rank csum (1, sk1, sk2)
1 1 1 1
1 2 2 (or 3?) 2
1 2 2 (or 2?) 3
1 3 4 4
Hope this does it for you.
Glenn Mc
|