zoukankan      html  css  js  c++  java
  • sql server 窗口函数去重和MOSS数据库获取


    select *
    from(
    SELECT ROW_NUMBER() over (partition by a.cameraip,a.carPlate order by a.cameraip,a.intime) num,*
    FROM [Camera].[dbo].[truck_Gate] a with(nolock)
    where intime>'2019-02-27'
    )a
    where a.num = 1
    order by a.cameraip,a.intime

    按摄像头类型,时间来去掉重复


    //MOSS数据获取考勤sql
    with t1 as (
    select
    case when cast(tp_ContentTypeId as int)=-135314910 then N'出差培训'

    when cast(tp_ContentTypeId as int)=-339275661 then tp_ColumnSet.value(N'data(/nvarchar6)[1]', 'nvarchar(30)')
    when cast(tp_ContentTypeId as int)=1808594290 then N'加班'
    when cast(tp_ContentTypeId as int) =-888033353 then N'补休'
    else N'值班'
    end type1 ,

    b.tp_Title,[tp_Created] ,CONVERT(varchar(10), [tp_Created], 23) as 日期,tp_ColumnSet
    , SUBSTRING(tp_ColumnSet.value('data(/datetime1)[1]', 'varchar(30)'),0,11) as 日期1,
    tp_ColumnSet.value(N'data(/nvarchar6)[1]', 'nvarchar(30)') as 假期

    from WSS_Content_80_XXJS.[dbo].[AllUserData] a left join [WSS_Content_80_XXJS].[dbo].[UserInfo] b on a.tp_Author=b.tp_ID

    where

    [tp_ListId]='4516AEC6-1278-4A7D-BC46-521A1F112F7A' and dateadd(HOUR,8,[tp_Created]) >'2019-06-01'

    and dateadd(HOUR,8,[tp_Created]) <'2019-07-01'

    --and tp_Author in(57,376)
    )

    select b.empcname,b.attrulename,b.schdate,t1.type1 from [AS0801_OnLine].[dbo].[V_SchResultInfoAll] b
    left join t1 on t1.tp_Title=b.empcname collate Chinese_PRC_90_CI_AI and t1.日期1=b.schdate collate Chinese_PRC_90_CI_AI
    where b.schdate>'2019-06-01' and b.schdate<'2019-07-01'

  • 相关阅读:
    批量数据导入数据库方法
    Remoting简单实践
    js面向对象继承
    Linq实现t-Sql的各种连接
    数据库树状结构的关系表的删除方案
    记录一次SQL查询语句
    mvc请求过程总结
    T-sql表表达式
    各个浏览器的兼容问题及样式兼容处理(不定期补充)
    vue.js 键盘enter事件的使用
  • 原文地址:https://www.cnblogs.com/mlwork/p/11528733.html
Copyright © 2011-2022 走看看