【发布时间】:2019-03-13 08:07:15
【问题描述】:
我有一个名为 tbl1 的表。其中包含 3 列 empId、Designation 和 SalaryScale
empId Designation salaryScale
Arun Developer 1
Kiran Developer 0
Anu ITA 2
我想获取具有特定指定为 DesCount 的人的总数,并且需要获取每个指定的salaryScale 计数,其中薪级 > 0 并将它们聚合到指定级别。
下面是我的查询和输出
选择 Designation,count(Designation) 作为 DesCount,count(salaryScale) as scaleCount from tbl1 wheresalaryScale>0 group by Designation;
Designation DesCount scaleCount
Developer 1 1
ITA 1 1
但我期待的是
Designation DesCount scaleCount
Developer 2 1
ITA 1 1
因为对于 Developer 指定,总数为 2。
我在查询中做错了吗?
【问题讨论】: