行号()结束 [英] ROW NUMBER() OVER

查看:32
本文介绍了行号()结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个有点特殊的语法,你能帮我弄清楚它是什么意思吗?谢谢.

I came across a somewhat special syntax, could you help in figuring out what it means? Thank you.

SELECT ROW NUMBER() OVER (ORDER BY Product.ProductID) FROM Product;

此外,这也失败了.我对 ROW NUMBER() OVER 位特别感兴趣.这也是我第一次遇到 OVER 关键字.

Also, this fails. I'm particularly interested in the ROW NUMBER() OVER bit. It's the first time I've encountered the OVER keyword, too.

如果您需要完整示例,请告诉我.为了清楚起见,我把它缩短了一点.

Please let me know if you need the full example. I shortened it a bit for the sake of clarity.

推荐答案

ROW_NUMBER() 函数需要 OVER(ORDER BY) 表达式来确定行编号的顺序.默认顺序是升序,但也可以使用降序.由于 T-SQL 不允许在 T-SQL 之外检索游标,因此此函数可用于多种用途,例如在迭代一组记录时跟踪行.@tunimise fasipe 是正确的,你错过了 _

The ROW_NUMBER() function requires the OVER(ORDER BY) expression to determine the order that the rows are numbered. The default order is ascending but descending can also be used. This function is useful for a variety of things like keeping track of rows when iterating through a set of records since T-SQL does not allow a cursor to be retrieved outside of T-SQL. @tunimise fasipe is correct, you are missing the _

这篇关于行号()结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆