gpt4 book ai didi

sql - 如何将水平行转换为垂直 SQL Server

转载 作者:行者123 更新时间:2023-12-02 01:37:39 25 4
gpt4 key购买 nike

查询:

Select 
COUNT(aciklama)as Permitted,
(Select COUNT(aciklama)
from Uyari
where Aciklama like '%Blocked%') as Blocked
From
Uyari
where
Aciklama like '%Permitted%'

输出:

Permitted     Blocked
----------------------
74 9194

我想要这样的结果:

Permitted   ...      74
Blocked ... 9194

有人能帮忙吗?

最佳答案

这是一个使用 union all 的选项

select 'Permitted' action, COUNT(aciklama) as result
from Uyari
where Aciklama like '%Permitted%'
union all
select 'Blocked' action, COUNT(aciklama)
from Uyari
where Aciklama like '%Blocked%'

关于sql - 如何将水平行转换为垂直 SQL Server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30222790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com