Incrementing Counts in SQL
来源:互联网 发布:淘宝网中年女装40岁 编辑:程序博客网 时间:2024/06/05 00:52
Fairly frequently (particularly during Data Migration when deriving new key values) you have to rank and number rows within a particular key value. For instance, Key1 may have three rows – and these should be given a value of 1, 2 & 3. Key 2 however may have a different number of values but these should start again from 1. Example shown in this table:
ValueRowNumKey11Key12Key13Key21Key31Key32Key33Key34The Rownum field can be achieved in Oracle using the following SQL:
SELECT <Key1>
, rank() over (partition by <Key1> order by <OrderField> )
FROM <recname> k
As well as the RANK() function, there is a DENSE_RANK() function. The latter doesn’t leave gaps when there is a tie, for example RANK may give the output 1,2,2,4 where DENSE_RANK would give 1,2,2,3. The highest rank value provided by a DENSE_RANK statement would be the number of unique values.
Comments»
- Incrementing Counts in SQL
- Get MSMQ Queue Counts in C#
- query table row counts for versioned table in Netezza
- High SQL Version Counts - Script to determine reason(s)
- Incrementing and Decrementing Variables
- digit-counts
- Write a method that counts the number of occurrences of a given character in a string
- CNN数玉米穗--TasselNet: Counting maize tassels in the wild via local counts regression network
- High SQL Version Counts - Script to determine reason(s) (文档 ID 438755.1)
- TopCoder SRM 625 Incrementing Sequence 题解
- Badboy自动化测试工具 Incrementing Variables
- Badboy自动化测试工具8 Incrementing Variables
- SQL In
- sql in
- SQL IN
- Adjacent Bit Counts(P3786)
- hdu 4486 pen counts
- Uva 6174 Pen Counts
- 解决Xcode 4.3.2的"Could not insert new outlet connection"问题
- 新白娘子传奇
- NSString的比较
- 写给五岁生日的可可宝宝
- ViewState too large and setting the max number of controls in the one page by web config
- Incrementing Counts in SQL
- C语言中sizeof与strlen区别
- extern "C"详解
- poj3041 二分图的最小点覆盖
- linux学习路线浅谈(转载)
- cookie使用
- db2 中出现SQL0449 错误处理
- 一步一步走进字符驱动--自旋锁
- 加载模型
Thank you for this info
( : >s are interpreted in the source tag )
Good spot. I’ve changed the code to correct that now. Thanks!