[英]Oracle : group results by occurence
I'm having some issue with a specific select in Oracle : 我在Oracle中的特定选择方面遇到了一些问题:
Let's say we have a select returning those elements : 假设我们有一个选择返回那些元素:
Person Evaluation Date Hour Bryan A 10/12/2013 9:00 Ed D 10/12/2013 9:00 Julia A 10/12/2013 9:00 Will F 10/12/2013 9:00 Bryan B 10/12/2013 14:00 Ed C 10/12/2013 14:00 Julia A 10/12/2013 14:00 Will C 10/12/2013 14:00
I want to be able, in my query, to increment a value for each occurence of a specific element, juste like : 我希望能够在每次查询中为特定元素的每次出现增加一个值,就像:
Person Evaluation Date Hour Nb Bryan A 10/12/2013 9:00 1 Ed D 10/12/2013 9:00 1 Julia A 10/12/2013 9:00 1 Will F 10/12/2013 9:00 1 Bryan B 10/12/2013 14:00 2 Ed C 10/12/2013 14:00 2 Julia A 10/12/2013 14:00 2 Will C 10/12/2013 14:00 2
I tried dense_rank() with an over(partition by xxx order by xxx), but I only got that : 我尝试了一次over(按xxx顺序按xxx划分)的density_rank(),但是我只有这样:
Person Evaluation Date Hour Nb Bryan A 10/12/2013 9:00 1 Ed D 10/12/2013 9:00 2 Julia A 10/12/2013 9:00 3 Will F 10/12/2013 9:00 4 Bryan B 10/12/2013 14:00 1 Ed C 10/12/2013 14:00 2 Julia A 10/12/2013 14:00 3 Will C 10/12/2013 14:00 4
Try removing the partition by
clause: 尝试删除partition by
子句:
dense_rank() over (order by xxx)
In your case, that would be: 您的情况是:
dense_rank() over (order by "hour")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.