我正在编辑一个创建View的查询。我添加了一个案例,用于搜索字段等于特定值的记录并输出一个int值 像3一样名为Status的View列。我正在处理服务器并且不想将查询保存到视图中。我运行查询并生成 新的状态值,例如' 3'在专栏中。我不确定如何计算View查询中状态为3的记录的出现次数。我该怎么办 那?我不想保存查询,然后针对View运行查询。我想执行查询并生成值为Status = 3
的记录计数由于
select
rtrim(p.PP) as Id,
(case (p.PC) when '17' then 'B' when 'W' then 'NN' end) as Company,
rtrim(p.PP as Number,
'Application' as [Type],
(case end) as [Status],
'--' as [Source],
case end as Channel,
case
when p.PENDP_PRODDESC like '%associaterm%' then 1
else 0
end as IsPrivate,
case
when (r.COLUMN1 = 'P' and (r.COLUMN2 = 'IC') then '3'
else '0'
end as Status,
p.PR_IND as RS
from MY_TABL as p
left join U_TABL as tu on p.PC = tu.U_COMPANY and p.PP = tu.U_TUNUMBER
答案 0 :(得分:1)
select count(*)
from (<paste your select here>) as vw_sql
where vw_sql.status = '3'