當(dāng)前位置:首頁(yè) > IT技術(shù) > 數(shù)據(jù)庫(kù) > 正文

sql 多條單行 查詢數(shù)據(jù) 轉(zhuǎn)為一行
2021-09-11 10:31:30

?

select * from(
select Id=1, count(1)as 待審核 from T_TaskManage where  CompleteState = '待審核'
)A
left join(
    select Id=1, count(1)as 未完成 from T_TaskManage where  CompleteState = '未完成'
)B
on
A.Id = B.Id
left join(
    select Id=1, count(1)as 已完成 from T_TaskManage where  CompleteState = '已完成'
)C
on
A.Id = C.Id
left join(
    select Id=1, count(1)as 延期完成 from T_TaskManage where  CompleteState = '延期完成'
)D
on
A.Id = D.Id

?

本文摘自 :https://www.cnblogs.com/

開通會(huì)員,享受整站包年服務(wù)立即開通 >