Friday, July 16, 2010

Teradata Sequence

Here I will give a Teradata work around for sequence (oracle users). This is not a DDL based solution. It will generate values on the fly using query. Find the example below:-

SEL
ROW_NUMBER() OVER (PARTITION BY 'A' ORDER BY COL1) AS SEQ,
COL1,
COL2
FROM
(
SEL
COL1,
COL2
FROM MYTABLE
)TMP;

The explanation is when you partion by a constant value (in this case 'A'), full table becomes one partition. As a result row number is assigned on the basis of the ordered columns. For any doubts leave a comment.

0 comments:

Disclaimer

Experiment with the things mentioned in this blog at your own risk. The author shall not be held responsible for any damages caused to your system by the things mentioned in the blog.

Notice

All logos, trademarks, images used are property of their respective organizations. If any organization has objection to any post regarding use of their property I will happily remove it.