0

我正在尝试根据产品的高度设置退货结果。如果产品大于 86,我想返回 Transom 以及结果集,如果它小于我返回 No Transom 的内容。

我正在尝试使用下面的 CASE WHEN 来评估结果,但我的实现不正确。

    SELECT c.ID, 
        (p.Number +'|'+ pr.[Profile] +'|'+ SUBSTRING(CAST((p.Width - (pr.Siteline * 2))AS VARCHAR(9)),0,3)  
        + 'x84' +'|Pivot:'+e.PivotType+'|Hinge:'+e.Hinged +'|Swing:'+e.Swing) as [Name],
        ('Header:'+ CAST(pr.Siteline as VARCHAR(7))+'|Jamb:'+ CAST(pr.Siteline as VARCHAR(7)))as[Sitelines],

       CASE p.Height 
            WHEN > 86 THEN 'Transom'
            ELSE 'No Transom'

FROM            Generic.Part           p WITH(NOLOCK)                          JOIN
                Generic.Profiles      pr WITH(NOLOCK) ON p.ProfileID = pr.ID   JOIN
                Generic.ComponentPart cp WITH(NOLOCK) ON cp.PartID   = p.ID    JOIN
                Generic.Component      c WITH(NOLOCK) ON cp.ComponentID = c.ID JOIN
                Generic.ComponentType ct WITH(NOLOCK) ON ct.ID = c.ComponentTypeID JOIN
                Generic.FramingSystem fs WITH(NOLOCK) ON fs.ID = c.FrameSystemID   JOIN
                Generic.Entrance       e WITH(NOLOCK) ON c.ID = e.DoorFrameID
                WHERE fs.UserID = 'DA91DC34-FA29-4ABD-BCC0-xxxxxxxxxxxx'
4

2 回答 2

4

您没有说实际错误是什么,但请尝试:

CASE
    WHEN p.Height > 86 THEN 'Transom'
    ELSE 'No Transom'
END AS [ColumnName]
于 2013-10-23T22:38:30.037 回答
1

你只是错过了END

   CASE p.Height 
        WHEN > 86 THEN 'Transom'
        ELSE 'No Transom'
   END
于 2013-10-23T22:39:24.427 回答