2019-02-27
阅读量:
708
如何查询某字段相同数据出现次数大于3的信息?
如何查询某字段相同数据出现次数大于3的信息?
select num ,count(num) as new_num
from xxy_logs
group by num
where new_num>3;
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where new_num>3' at line 4
答:where 关键字不能和group by 一起使用的(主要是不能放在group by 之后,不能作用于聚合后的数据),这时我们可以使用hiving语句来过滤返回的记录集,可以按照下面的方式k来写。
select num ,count(num) as new_num
from xxy_logs
group by num
HAVING new_num>3;






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论