标签:str 获取 bsp tle 计算 sum exists 函数 to_date
select title, count(emp_no) as t
from titles
group by title
having t >= 2
解题关键:
1、用count函数而不是sum函数;
2、这里用having而不是where
where子句在分组之前过滤数据,在GROUPBY语句之前,SQL会在分组之前计算WHERE语句;
having子句在分组之后过滤数据,在GROUPBY语句之后,SQL会在分组之后计算HAVING语句。
标签:str 获取 bsp tle 计算 sum exists 函数 to_date
原文地址:https://www.cnblogs.com/pan2575184309/p/10434784.html