用select count(...)能不能同时计算出一个表中的两个以上的字段的相应条件的值?即得出几个count值
如:
Table:
ID ID2 ID3
----- ------ -------
1, 11, 111
2, 22, 222
3, 33, 333
如何一次就得出如下的结果:
Output:(要求的条件:ID > 2 , ID3 >100)
IDCount ID3Count
--------- -----------
1, 3
---------------------------------------------------------------
select (select count() from yourTable where ID>2) IDCount,
(select count() from yourTable where ID3>100) ID3Count
---------------------------------------------------------------
对,子查询..
同意楼上的斑竹GG
---------------------------------------------------------------
select id2,id3 from (select count()id2 from yourTable where id1>2) as i1,(select count()id3 from yourTable where id3>100) as i3