【发布时间】:2018-08-05 09:37:58
【问题描述】:
我有一张表,其中一个人在另一列中多次包含相同的值。
例如:
person product portal count indicator
-----------------------------------------------
1 10 5 2 y
1 10 6 2 y
1 15 7 1 y
select person, count(person) over(partition by product)
from table A
如果一个人多次包含相同的产品,那么在这种情况下,我想识别这样的人群并想给它一些类型的指标。
在上面的示例中,产品 10 出现了多次,所以我想为所有行的人提供一个指示符。
【问题讨论】:
-
为什么把sql中的保留关键字全部用为table_name和column_name
-
尝试使用 distinct select * from (select person, count(distinct person) over(partition by product) cnt from table A ) where cnt>1;
标签: sql-server oracle amazon-redshift-spectrum