相关疑难解决方法(0)

SQL Server 2008中"WHERE"子句中的"CASE"语句

我正在使用一个查询,其中包含"WHERE"子句中的"CASE"语句.但SQL Server 2008在执行时会出现一些错误.任何人都可以帮我正确的查询?这是查询:

SELECT
    tl.storenum 'Store #', 
    co.ccnum 'FuelFirst Card #', 
    co.dtentered 'Date Entered',
    CASE st.reasonid 
        WHEN 1 THEN 'Active' 
   WHEN 2 THEN 'Not Active' 
   WHEN 0 THEN st.ccstatustypename 
   ELSE 'Unknown' 
    END 'Status',
    CASE st.ccstatustypename 
        WHEN 'Active' THEN ' ' 
   WHEN 'Not Active' THEN ' ' 
   ELSE st.ccstatustypename 
    END 'Reason',
    UPPER(REPLACE(REPLACE(co.personentered,'RT\\\\',''),'RACETRAC\\\\','')) 'Person Entered',
    co.comments 'Comments or Notes'
FROM 
    comments co
    INNER JOIN cards cc ON co.ccnum=cc.ccnum
    INNER JOIN customerinfo ci ON cc.customerinfoid=ci.customerinfoid
    INNER JOIN ccstatustype st ON st.ccstatustypeid=cc.ccstatustypeid
    INNER JOIN …
Run Code Online (Sandbox Code Playgroud)

sql sql-server case

101
推荐指数
4
解决办法
80万
查看次数

标签 统计

case ×1

sql ×1

sql-server ×1