zoukankan      html  css  js  c++  java
  • SQL语句

    1、--按天查询(本月)
    select Id, ActiveTotal,(DataDate) from DimEnergyFrozen WHERE MeterId=5 And DATEDIFF(MONTH,DataDate,GETDATE())=0 order by DataDate;

    2、--取去年一年的每月数据
    select YEAR(UPDATETime) '年',Month(UPDATETime) '月',Sum(ActiveTotal) '总计' from DimEnergyFrozen where UpdateTime<DATEADD(YYYY,-1,GETDATE()) and UpdateTime >DATEADD(YYYY,-2,GETDATE()) group by YEAR(UPDATETime),Month(UPDATETime) Order by YEAR(UPDATETime),MONTH(UPDATETime)

    3、--取现在1年的每月数据
    select YEAR(DataDate) '年',Month(DataDate) '月',Sum(ActiveTotal) '总计' from DimEnergyFrozen where DataDate<GETDATE() and DataDate >DATEADD(YYYY,-1,GETDATE()) group by YEAR(DataDate),Month(DataDate) Order by YEAR(DataDate),MONTH(DataDate)

    4、--按月总计(用户表5)
    select YEAR(UPDATETime) '年',Month(DataDate) '月',Sum(ActiveTotal) '总计' from DimEnergyFrozen where MeterId=5 group by YEAR(UPDATETime),Month(DataDate) Order by MONTH(DataDate) DESC


    ==========================

  • 相关阅读:
    liststyle
    :nthchild(n)
    织梦CMS首页调用分类信息栏目及列表方法
    []织梦CMS首页调用分类信息栏目及列表方法
    ps快捷键
    系统架构博客,很不错
    google maps api 反向解析 地址 api
    sphinx
    sphinx discuss
    ruby分词
  • 原文地址:https://www.cnblogs.com/yuwentao/p/9807169.html
Copyright © 2011-2022 走看看