create table test(topicId int,parentId int)
insert test select 1,0
union all select 2,1
union all select 3,1
union all select 4,0
union all select 5,4select 主题总数=sum(case parentId when 0 then 1 else 0 end),
回复总数=sum(case when parentId=0 then 0 else 1 end)
from test主题总数 回复总数
----------- -----------
2 3(所影响的行数为 1 行)
insert test select 1,0
union all select 2,1
union all select 3,1
union all select 4,0
union all select 5,4select 主题总数=sum(case parentId when 0 then 1 else 0 end),
回复总数=sum(case when parentId=0 then 0 else 1 end)
from test主题总数 回复总数
----------- -----------
2 3(所影响的行数为 1 行)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货