我有一张桌子ABC
。我正在使用查询
select count(*) from ABC where COLA=123; //output is 3
select count(*) from ABC WHERE COLA=321; //output is 6
我希望两个输出结合起来像
| someColumnName |
| 3 |
| 6 |
有没有办法构建查询框架以便我可以实现这个目标?
答案 0 :(得分:4)
使用group by和where子句。
SELECT count(*) as SomeColumnName
FROM ABC
WHERE COLA in (123,321)
GROUP BY ColA
答案 1 :(得分:0)
另一种选择:
SELECT count(*) as SomeColumnName
FROM ABC
WHERE COLA = 123
OR COLA = 321
GROUP BY COlA;
:)