row_number限制与视图
我正在测试一个简单的查询部分,该部分从视图而不是表运行。当我忽略Row_number线时,查询返回结果。有了这一行活动,我只会得到无效的结果。是否有一定的限制反对在某种程度上进行此类操作?
SELECT
`VMC Savings`,
ROW_NUMBER() OVER (ORDER BY `VMC Savings`) AS row_n
FROM v_vmc_summary
I'm testing a simple query section that runs from a view instead of a table. When I leave out the ROW_NUMBER line, the query returns results. With this line active, I just get NULL results. Is there some restriction against doing these kinds of operations on a view?
SELECT
`VMC Savings`,
ROW_NUMBER() OVER (ORDER BY `VMC Savings`) AS row_n
FROM v_vmc_summary
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
评估每个记录的分区没有分区,并且是否存在零记录;空将替换每个值。
通过完整键的分区或过滤删除无效结果。
“按子句分区是ROW_NUMBER函数的可选部分,如果您不使用它,则结果集的所有记录都将被视为单个记录组或单个分区的一部分,然后应用排名函数。”
来源上述: https:/ /www.c-sharpcorner.com/blogs/Rownumber-function-with-with-by-clause-clause-in-sql-server1 ,
但我相信它也适用于mysql ..
因为它将其视为一种单分区;无效,无效需要特殊处理...我认为存在问题。
我想如果您愿意为0,则可以合并(值为0)。
without a partition by every record is evaluated and if null exists; Null will replace every value.
Partition by the complete key or filter out null results.
"Partition by clause is an optional part of Row_Number function and if you don't use it all the records of the result-set will be considered as a part of single record group or a single partition and then ranking functions are applied."
above source: https://www.c-sharpcorner.com/blogs/rownumber-function-with-partition-by-clause-in-sql-server1
but I believe it applies to mysql as well..
Since it looks at it as a single partition; and NULL exists and null needs special handling... I think there in is the problem.
I suppose you could coalesce(value,0) if you are willing the nulls to be 0.