`
baiiiuuu
  • 浏览: 41103 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

取出时间段的年份,并且进行统计

 
阅读更多
select y, COUNT(*) from 
(select (select DATEPART(year, time)) as y, * from warning_info) newtable where time <= ( select max(time) from warning_info) 
and time>=(select min(time) from warning_info) and status = 70
group by newtable.y

 

 

思路:先取出表数据的年份,然后再创建新的表,最后分组统计

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics