【发布时间】:2017-06-19 14:09:39
【问题描述】:
如何在删除重复行的同时合并行?
我尝试了UNION 本身以及UNION DISTINCT,但都在 Hue 中返回了错误消息。
编译语句时出错:失败:parseexception line 5:10 不匹配的输入 'distinct' 期望集合运算符中的所有接近 'union'
SELECT DISTINCT(product1.user)
FROM product1
UNION
SELECT DISTINCT(product2.user)
FROM product2
UNION
SELECT DISTINCT(product3.user)
FROM product3
【问题讨论】:
-
只使用联合。
Select product1.user from product1 union select user from product2 ...。Union自动删除重复项。Union all保留它们。 -
我自己尝试联合并得到错误:
error while compiling statement: failed: parseexception line 4:4 missing all at 'select' near '' line 7:4 missing all at 'select' near '' -
您使用的是 1.2 之前的版本吗?如果是这样,则仅支持 union all。如果是这样,您将不得不使用 union all,并围绕它包装一个外部查询以获得不同的。
select distinct user from (select user from product1 union all select user from product2...) t. -
在 1.0.0 上,感谢@Andrew
-
感谢@Andew,它也对我有用。