• select 中的逻辑判断 sql server


    SELECT     CASE field0010 WHEN '计划' THEN 1 ELSE 2 END AS s
    FROM         formmain_5991
    SELECT
           
    CASE WHEN (IFNULL(o.ENDTIME,99))=99
    THEN
    (CASE WHEN (CURDATE()-pc.FORECASTTIME)>0
    THEN
    (CASE WHEN (CURDATE()-pc.FORECASTTIME)>7 THEN 2 ELSE 1 END)
    ELSE
    0
    END)
    ELSE 0
    END AS overtime
    
    FROM  tb_a

    select case
           when 项目名称  IS NULL
           then '空值'
           when 项目名称 ='北二环'
           then 'A'
           when 项目名称 ='北三环'
           then 'B'
           else 'C'
           END  项目名称
    from   物件设计数量统计表
    
    
    SELECT     field0001 AS 项目名称, field0002 AS 项目编号, field0003 AS 计划开始, field0004 AS 计划结束, field0005 AS 节点名称, 
                          CASE field0010 WHEN '计划' THEN field0012 ELSE CASE isnull(field0012, 0) WHEN 0 THEN field0003 WHEN 1 THEN field0012 END END AS 节点开始时间, 
                          CASE field0010 WHEN '计划' THEN field0013 ELSE CASE isnull(field0013, 0) WHEN 0 THEN getdate() WHEN 1 THEN field0013 END END AS 节点结束时间, 
                          CASE field0010 WHEN '计划' THEN field0013 ELSE field0013 END AS 节点里程碑时间, field0006 AS 节点编号, field0010 AS 节点类型
    FROM         formmain_5991
     
  • 相关阅读:
    such用法
    divorce用法
    towel用法
    go for用法
    catch on用法
    incredibly用法
    mess用法
    dentist用法
    steer clear of用法
    incredible
  • 原文地址:https://www.cnblogs.com/lionmxs/p/10825531.html
Copyright © 2020-2023  润新知