计算包含特定值的总记录 [英] Count the total records containing specific values
本文介绍了计算包含特定值的总记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题,希望你们能帮助我.
I have a question and hope you guys can assist me.
我有一个包含两列的表:
I have a table containing two columns:
type // contains 2 different values: "Raid" and "Hold"
authorization // contains 2 different values: "Accepted" or "Denied"
我需要制作一个返回这样的值的视图:
I need to make a view that returns values like this:
TYPE:RAID ACCEPTED:5 DENIED:7
基本上我想知道TYPE
中有多少个值是突袭",然后有多少个
它们是已接受"和已拒绝".
Basically I want to know how many of the values in TYPE
are "Raid" and then how many of
them are "Accepted" and "Denied".
先谢谢您!
推荐答案
SELECT
Type
,sum(case Authorization when 'Accepted' then 1 else 0 end) Accepted
,sum(case Authorization when 'Denied' then 1 else 0 end) Denied
from MyTable
where Type = 'RAID'
group by Type
这篇关于计算包含特定值的总记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文