简体   繁体   English

视图中数据的滚动编号

[英]Rolling numbering of data in a view

I am using the following query to number the data based on parameter a and b.我正在使用以下查询根据参数 a 和 b 对数据进行编号。

count(table.a) OVER (PARTITION BY table.b, tdahw.a ORDER BY table.date) AS row_count

The output is numbering the values as incremental.输出将值编号为增量。 However, if there are 3 counts of a over partition of a and b, I want it to display 3 across all the rows.但是,如果 a 和 b 的过度分区有 3 个计数,我希望它在所有行中显示 3 个。 What tweaks should I make to the existing thing?我应该对现有事物进行哪些调整?

Sample data:样本数据:

enter image description here在此处输入图片说明

Just remove order by :只需通过以下方式删除订单:

select count(m.a) OVER (PARTITION BY m.b, m.a) AS row_count 
from mytable m

Here is a simple demo I created:这是我创建的一个简单演示:

DEMO 演示

So for you it would be :所以对你来说是:

count(table.a) OVER (PARTITION BY table.b, tdahw.a) AS row_count

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM