SELECT concat(t1.description,t1,number, t1.date) AS UID,
CASE WHEN t2.NUM_TIMES_UID <= 1 THEN 'y' ELSE 'dummy' END AS DUMMY_VAR
FROM table t1
LEFT JOIN (
SELECT
concat(description,number, date) AS UID,
SUM(1) AS NUM_TIMES_UID
FROM table
GROUP BY
concat(description,number, date)
) t2 ON (concat(t1.description,t1,number, t1.date) = concat(t2.description,t2,number, t2.date))
with items as (
select concat(description,number, date) as item
from table1
group by concat(description,number, date)
)
select item, count(item) as item_cnt
from items
group by item
2条答案
按热度按时间zpqajqem1#
如果按连接的字符串分组,则已获得所有不同的组合。只需再添加一个字段,就可以知道每行显示sum(1)或count(1)/count(*)的次数。
编辑
g0czyy6m2#
返回分组行和该行在输入表中存在的次数的简单决策: