zoukankan      html  css  js  c++  java
  • 笛卡尔积的使用

    WITH C AS (select 
    [day1],[day2],[day3],[day4],[day5],[day6],[day7],[day8],[day9],[day10],[day11],[day12],[day13],[day14],[day15],[day16]
    ,[day17],[day18],[day19],[day20],[day21],[day22],[day23],[day24],[day25],[day26],[day27],[day28],[day29],[day30],[day31]
    from  [MMS_WorkdayDefinition]
    where companyid='b0ba1259-54cc-4122-b66e-41988ac531ef'
    and yeardate='2017-11-01' 
    ),
    C2 AS (
    SELECT  d=attribute, v=value
    FROM (select * from C)a
    UNPIVOT
    (
    value FOR attribute IN([day1]
    ,[day2],[day3],[day4],[day5],[day6],[day7],[day8],[day9],[day10],[day11],[day12],[day13],[day14],[day15],[day16],[day17]
    ,[day18],[day19],[day20],[day21],[day22],[day23],[day24],[day25],[day26],[day27],[day28],[day29],[day30],[day31])
    ) AS UPV
    WHERE value IS NOT NULL
    )
    select d,bc from (
    select * from C2 cross join (select id as bc,ISZB from [MMS_ShiftSettings]
    where companyid='119419e3-c0d2-426d-9287-7572822c2d2e') t where C2.v<>1 or t.ISZB<>1
    ) k 
    Except
    select  CONVERT(VARCHAR(100), 'day',112)+CONVERT(VARCHAR(100), DATepart(dd, SetDate),112) AS d ,setting as bc 
    from  [MMS_SchedulingAdjustment] sd
    where CONVERT(VARCHAR(6), SetDate, 112)='201711' and sd.ISZB=1
    and companyid='b0ba1259-54cc-4122-b66e-41988ac531ef'
    group by setting, SetDate
  • 相关阅读:
    C语言之浮点类型
    C语言之变量基本使用
    Linux之Shell位置参数变量
    C语言之字符类型
    Linux之设置环境变量
    C# 获取任何给定类型Type的三种形式
    指针 PointerPlayground2 示例
    mount bind
    mono2.10.9]# ./configure help
    创建基于栈的数组
  • 原文地址:https://www.cnblogs.com/fengduandeai/p/8628625.html
Copyright © 2011-2022 走看看