SELECT REF_ID, MIN(SLA) FROM [SLA] WHERE [FIRST_DATE] > '2016-09-30' GROUP BY [REF_ID]
当存在重复时,这将列出具有最小SLA的项目
REF_ID | COUNT
11 | 1
12 | 1
13 | 1
14 | 2
我想获得SLA的数量,有人可以为此提供查询。
SLA | COUNT
1 | 3
2 | 1
0 | 0
由于
答案 0 :(得分:1)
获取SLA的数量:
select SLA, count(SLA) from table group by SLA
答案 1 :(得分:1)
试试这个
SELECT MINSLA, COUNT(MINSLA)
FROM (SELECT REF_ID, MIN(SLA) AS MINSLA
FROM [SLA]
WHERE [FIRST_DATE] > '2016-09-30'
GROUP BY [REF_ID]
) r
GROUP BY MINSLA