双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

求sql里查询连续五天大于某数值的语句2

snail_t snail_t 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
上次发了一个帖子,想要求sql里查询连续五天大于某数值的语句
帖子的地址是:http://bbs.csdn.net/topics/390703059
经过网友们的帮助,给出了以下语句进行查询
select *
from
(select min([年月日]) as bgdate, max([年月日]) as eddate, count(1) as maxdays
from
(select [年月日], datediff(dd, '1900-01-01', a.[年月日]) - (select count(1) from ##DateData58549 b where [日平均温度] >= 10 and datediff(dd, b.[年月日], a.[年月日]) >= 0) as maxdays
from ##DateData58549 a
where [日平均温度] >= 10) a
group by maxdays
having COUNT(1) >= 5
) b
order by bgdate
我不太看得懂a和b的指代关系,请问该找哪方面的文献?
另外,想要求出每年出现“连续五天大于某数值”的第一天,即一年只求一天,上述sql语句该怎么改呢?
...全文

相关推荐

用My SQL查询连续的数字(连续出现问题)

最近在leetcode上刷题的时候,发现了一个比较有代表性的查询连续出现数字的问题。当然这个连续出现问题可以是很多,连续签到、连续登陆等。这个时候需要用到自连接,自连接也就是把一张表当两张表用。 比如这道题: 为了看起来舒服一些,我在自己的workbench上测试的时候没有用这张表,不过道理是一样的。 1、先建表 # 先建立一张试验用的表stu_score。 create table stu_score(id int not null, fenshu int not null,primary key(id)); insert into stu_score(id,fenshu) value(1

weixin_38703123

SQL语句,查询当月,当年数据

当月数据 select * from table t where t.create_time >=TRUNC(SYSDATE, 'MM') and t.create_time=trunc(sysdate,'YYYY') and t.create_time=trunc(sysdate,'day')+1 and t.create_time=trunc(next_day(sysdate-8,1)+1) and t.create_time<=trunc(next_day(sysdate-8,1)+7) select trunc(next_day(sysdate - 8, 1) + 1) as 周一, trunc(next_day(sysdate - 8, 1) + 2) as 周二, trunc(next_day(sysdate - 8, 1) + 3) as 周三, trunc(next_day(sysdate - 8, 1) + 4) as 周四, trunc(next_day(sysdate - 8, 1) + 5) as 周五, trunc(next_day(sysdate - 8, 1) + 6) as 周六, trunc(next_day(sysdate - 8, 1) + 7) as 周日 from dual;

dengf1984

使用sql语句查询日期

使用sql语句查询日期 select * from ShopOrder where datediff(week,ordTime,getdate()-1)=0 //查询当天日期在一周年的数据 select * from ShopOrder where datediff(day,ordTime,getdate()-1)=0 //查询当天的所有数据 --查询当天: select * from info where DateDiff(dd,datetime,getdate())=0

dzmking

SQL时间查询语句

各种时间查询语句!年月日~星期,钟点。应有尽有!

wlianj

java执行SQL语句实现查询的通用方法详解

主要介绍了java执行SQL语句实现查询的通用方法详解,具有一定借鉴价值,需要的朋友可以参考下。

weixin_38702110
评论 3
收藏 已收藏
分享
返回顶部
snail_t
应用实例 27,579 成员 68,540 内容