設置我的表像下面SQL單行結果從多個SQL
create table #temp
(
a int null,
b int null,
c int null,
d int null
)
insert into #temp values (0,0,0,0)
insert into #temp values (0,1,0,0)
insert into #temp values (0,0,0,1)
insert into #temp values (0,1,0,0)
我試圖
select * from(
(select count(*) a from #temp where a=1 group by a) dt1 cross join
(select count(*) b from #temp where b=1 group by b) dt2 cross join
(select count(*) c from #temp where c=1 group by c) dt3 cross join
(select count(*) d from #temp where d=1 group by d) dt4
)
,但沒有得到任何輸出
我想輸出像下面
a b c d
0 2 0 1
如何實現S'
謝謝Sreenu131 – Geeme