Mar*_*usJ 1 sql-server filtering case
我想知道是否可以根据查询中的“样式”列轻松过滤结果。
select distinct
m.ManagerName,
p.ProductName,
p.slocumrank,
case
when s2.SubType2ID = 45 then 'Large Cap'
else s2.SubType2Name
End + ' ' + s1.SubType1Name as 'Style'
from QuantPerformance qp
where Style = 'ABCD'
Run Code Online (Sandbox Code Playgroud)
目前,我的 where 语句过滤掉了所有内容。
SELECT * FROM
(
SELECT DISTINCT ManagerName
, ProductName
, slocumrank
, case when SubType2ID = 45
then 'Large Cap'
else SubType2Name
End + ' ' + SubType1Name AS [Style]
from QuantPerformance
) A
where A.Style = 'ABCD'
Run Code Online (Sandbox Code Playgroud)
SELECT DISTINCT ManagerName
, ProductName
, slocumrank
, case when SubType2ID = 45
then 'Large Cap'
else SubType2Name
End + ' ' + SubType1Name AS [Style]
from QuantPerformance
where case when SubType2ID = 45
then 'Large Cap'
else SubType2Name
End + ' ' + SubType1Name = 'ABCD'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3657 次 |
| 最近记录: |