所以我的桌子上有这样的记录
表
ID Department
1 Finance
2 Engineering
3 IT
4 Finance
5 IT
6 IT
我应该能够得到:
Count Department
3 IT
2 Finance
1 Engineering
有什么想法吗?
谢谢
答案 0 :(得分:1)
使用WHERE
限制行。
SELECT id, 1 AS valid, Department
FROM RECORDS
WHERE DATEDIFF(quitDate, hiredDate) < 730 AND Department = 'IT'