在数据集中的每个重复方面的计数?
我想为从查询中的数据集中的每个出现一个值添加一个串联计数。
示例数据集:
ID OtherValue
00A 2ndValue_1
00A 2ndValue_2
00A 2ndValue_3
00A 2ndValue_4
00B 2ndValue_1
00C 2ndValue_1
00D 2ndValue_1
00D 2ndValue_2
我不确定查询以生成此数据集:
ID OtherValue ConcatinatedCount
00A 2ndValue_1 00A-001
00A 2ndValue_2 00A-002
00A 2ndValue_3 00A-003
00A 2ndValue_4 00A-004
00B 2ndValue_1 00B-001
00C 2ndValue_1 00C-001
00D 2ndValue_1 00D-001
00D 2ndValue_2 00D-002
我不太确定如何每行获得此计数。
I want to add a concatenated count for each occurrence of a value in a dataset from query.
Example dataset:
ID OtherValue
00A 2ndValue_1
00A 2ndValue_2
00A 2ndValue_3
00A 2ndValue_4
00B 2ndValue_1
00C 2ndValue_1
00D 2ndValue_1
00D 2ndValue_2
I wand the query to produce this dataset:
ID OtherValue ConcatinatedCount
00A 2ndValue_1 00A-001
00A 2ndValue_2 00A-002
00A 2ndValue_3 00A-003
00A 2ndValue_4 00A-004
00B 2ndValue_1 00B-001
00C 2ndValue_1 00C-001
00D 2ndValue_1 00D-001
00D 2ndValue_2 00D-002
I am not quite sure how to get this count per row.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
窗口函数(也称为分析功能或有序分析功能)是解决此问题的方法。
row_number()
窗口funtion将在每个不同id> id
的分区/组中生成一个行号,并且它将通过eathervalue 在组内。一些串联和格式,它应该吐出您所追求的。
Window Functions (also called Analytics Functions or Ordered Analytics Functions) are the way to solve this.
That
ROW_NUMBER()
window-funtion will generate a row number within the partition/group of each distinctID
and it will order that row number byOtherValue
within the group. Some concatenation and formatting and it should spit out what you are after.