sql:
SELECT
id, COUNT(id) AS Counter
FROM tableA
GROUP BY id
结果:
目标是如下所示:
将(NULL ID)与ID = 09结合起来,使其为0 + 1 = 1,给id正确命名也很好,比如
ID Counter
NULLWITH09 1
THE 01 467
THE 02 8
任何帮助都会很棒..谢谢
答案 0 :(得分:1)
未经测试,但是这样:
SELECT
'THE ' +id, COUNT(id) AS Counter
FROM tableA
where id is not null and id<>9
GROUP BY id
UNION ALL
SELECT
'null and 9', COUNT(*) AS Counter
FROM tableA
where id is null or id=9