select ambiguity_name
from TBL_SAL_CUSTOMER
group by ambiguity_name
having count(distinct template_id)=1select ambiguity_name
from TBL_SAL_CUSTOMER
group by ambiguity_name
having count(template_id)=1
谁能说一下having count(distinct template_id)=1 与having count(template_id)=1 有啥区别
from TBL_SAL_CUSTOMER
group by ambiguity_name
having count(distinct template_id)=1select ambiguity_name
from TBL_SAL_CUSTOMER
group by ambiguity_name
having count(template_id)=1
谁能说一下having count(distinct template_id)=1 与having count(template_id)=1 有啥区别
去除了重复 template_id
insert # select 1, 'a'
insert # select 2, 'a'
insert # select 3, 'b'select a, count(distinct a) from # group by a
/*
a
---- -----------
a 1
b 1
*/
select a, count(a) from # group by a
/*
a
---- -----------
a 2
b 1
*/
count(distinct template_id)=1 → 去除了重复 template_id 指的是只有唯一的template_id才显示是吧
count(template_id)=1 显示的不也是只有唯一的template_id吗?因为前边的group by 已经把ambiguity_name分完类了