我有一个相当简单的问题
Select count(*) from tableTest
Where s_date >= current_date
Group by employee这是可行的,但我正在尝试导出这些记录,以便将某些员工分组到一个数字中
假设我有这样的记录
Employee | count
- - - - - - - - -
123 2
321 3
625 4
827 5
216 3但是,假设员工123的记录属于他们自己,但所有其他员工的编号都属于员工321
我如何才能将结果集更改为
Employee | count
- - - - - - - - -
123 2
321 15发布于 2019-02-23 08:25:18
使用case表达式:
select (case when employee = 123 then 123 else 321 end),
count(*)
from tableTest
where s_date >= current_date
group by (case when employee = 123 then 123 else 321 end);https://stackoverflow.com/questions/54836953
复制相似问题