问题
I am working with a Teradata warehouse, and I am using row_number in one of my sql scripts. The record set I am trying to use my script on is larger than the maximum of the integer value threshold. What to do in such a situation?
(casting the "row_number() over (par..)" expression to bigint did not work)
If you have found a solution for this problem in another DBMS, then I also welcome your solution as it might work in Teradata too.
回答1:
It is possible that just casting the value would work.
If not, try this:
select sum(cast(1 as bigint)) over (order by . . . Rows Unbounded Preceding)
Or, alternatively,
select csum(cast(1 as bigint), <order by column here>)
来源:https://stackoverflow.com/questions/16173192/row-number-over-2-billion-records-teradata