zoukankan      html  css  js  c++  java
  • case then 的用法 貌似case then不支持别名

    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go

    ALTER PROC [dbo].[usp_SRV_GetALLRelativeProject]
    @ServiceOrderID VARCHAR(50)
    AS
    /*
    PAGE: 通过服务单ID 获取该服务单关联的单子信息    
    Action: 服务单处理页面

    CreatedBy: XXX
    CreatedDate: 20101021
    ModifiedHistory:

    Test Scripts:

    EXEC usp_SRV_GetALLRelativeProject 'SRV000000014'

    */ 
    BEGIN
    SELECT d.[Type],
    d.TypeID,
    d.[Desc],
    d.VariationOrderID,
    CASE 
    WHEN d.WorkOrderStatus IS NULL THEN d.SrvOrderStatus
    ELSE d.WorkOrderStatus
    END AS Status,
    CASE 
    WHEN d.WorkOrderHName IS NULL THEN d.SrvOrderHName
    ELSE d.WorkOrderHName
    END AS HName
    FROM (
       SELECT r.[Type],
       r.TypeID,
       r.VariationOrderID,
       r.[Desc],
       a.DictName AS SrvOrderStatus,
       hand.HName AS SrvOrderHName,
       CASE wo.Status
       WHEN 1 THEN '处理中'
       WHEN 2 THEN '完成'
       END AS WorkOrderStatus,
       wo.HandlerName AS WorkOrderHName
       FROM dbo.tbl_VariationOrderRelativeProject r
       INNER JOIN tbl_ServiceOrder s
       ON r.VariationOrderID = @ServiceOrderID
       AND s.ServiceOrderID = @ServiceOrderID
       LEFT JOIN (
        SELECT * FROM dbo.tbl_Dictionary
        WHERE DictType = 'ServiceOrderStatus'
       ) a
       ON s.StatusCode = a.DictCode
       LEFT JOIN tbl_ServiceHandlerInfo hand
       ON r.VariationOrderID = hand.ServiceOrderID
       LEFT JOIN dbo.tbl_ServiceWorkOrder wo
       ON r.TypeID = wo.ServiceWorkOrderID
    ) d

    END

  • 相关阅读:
    JavaScript面向对象基础语法总结
    json对象
    关于JavaScript语法的小笔记
    关于JavaScript的小笔记
    html中的a标签的target属性的四个值的区别?
    详解Bootstrap 定义按钮的样式(CSS)
    (负)-margin在页面布局中的应用
    lorem ipsum text占位符
    jQuery动态添加元素事件
    实用|从0到1 搭建Web性能监控系统
  • 原文地址:https://www.cnblogs.com/niaowo/p/3859849.html
Copyright © 2011-2022 走看看