当我运行下面的查询时,得到错误“invalid column reference:cnt”。任何建议都会很好!!
select count(customer) as cnt from (
select customer, concat(visid, lowid), count(name)
from tab1 where date_time between '2017-05-01 00:00:00' and '2017-05-31 23:59:59' and name in ('payment: Complete', 'check: Complete')
group by evar71, concat(visid, lowid)) t1
where cnt > 1;
3条答案
按热度按时间cs7cruho1#
另一种方法。
oipij1gg2#
我觉得Hive更喜欢化名
group by
. 此外,有几个列别名不正确:mgdq6dx13#
WHERE
在聚合之前应用筛选器这就是原因where cnt > 1
不起作用。有HAVING
关键字,它在聚合后充当过滤器。