• 日期格式处理


    WITH Sequence
    AS
    (
    SELECT CONVERT(varchar(10),'2017-12-01',23) dtime
    UNION ALL
    SELECT
    CONVERT(varchar(10),DATEADD(mm,-1,dtime),23)
    FROM Sequence
    WHERE LEFT(CONVERT(varchar,DATEADD(mm,-1,dtime),21),7)>=LEFT(CONVERT(varchar,'2017-01',21),7)
    )
    select LEFT(CONVERT(varchar,s.dtime,21),7) as datatime,a.oneNum,a.secondNum from Sequence s left join (
    select LEFT(CONVERT(varchar,TraDate,21),7) as datatime,SUM(LocalCount) as oneNum,SUM(OutCount) as secondNum
    from dbo.TrafficFlow_staticsByDay where LEFT(CONVERT(varchar,TraDate,120),4)=2017 and BGStationCode='GM_08'
    group by LEFT(CONVERT(varchar,TraDate,21),7)
    ) a on LEFT(CONVERT(varchar,s.dtime,21),7)=a.datatime


    WITH Sequence
    AS
    (
    SELECT CONVERT(varchar(10),'2017-01-31',23) dtime
    UNION ALL
    SELECT
    CONVERT(varchar(10),DATEADD(dd,-1,dtime),23)
    FROM Sequence
    WHERE LEFT(CONVERT(varchar,DATEADD(dd,-1,dtime),21),7)>=LEFT(CONVERT(varchar,'2017-01',21),7)
    )
    select LEFT(CONVERT(varchar,s.dtime,21),10) as datatime,a.oneNum,a.secondNum from Sequence s left join (
    select LEFT(CONVERT(varchar,TraDate,21),10) as datatime,SUM(LocalCount) as oneNum,SUM(OutCount) as secondNum
    from dbo.TrafficFlow_staticsByDay where LEFT(CONVERT(varchar,TraDate,120),4)=2017 and BGStationCode='GM_08'
    group by LEFT(CONVERT(varchar,TraDate,21),10)
    ) a on LEFT(CONVERT(varchar,s.dtime,21),10)=a.datatime

  • 相关阅读:
    vue element 表格错位问题
    echarts tooltip 按值的降序显示 tip 信息
    前端 玫瑰花小样式
    echarts X轴数据过多批量显示
    微信js sdk的使用初步理解
    对象 的循环嵌套
    移动端拉起电话请求
    js后加版本号
    数组排序于数组去重
    es6数组的方法
  • 原文地址:https://www.cnblogs.com/luoguixin/p/9140760.html
Copyright © 2020-2023  润新知