datediff的使⽤⽅法(针对的是两个⽇期元素)
采⽤窗⼝函数的解法:
select
t1.id
from(
select
id,recordDate,Temperature,
lag(recordDate,1,'0000-00-00')over(order by recordDate) r_z,
datediff是字符型函数lag(Temperature,1,100)over(order by recordDate) t_z
from Weather
) t1
where t1.Temperature-t1.t_z>0 and dDate,t1.r_z)=1;
不采⽤窗⼝函数的解法:
SELECT
weather.id AS 'Id'
FROM
weather
JOIN
weather w ON DATEDIFF(weather.date, w.date) = 1
AND weather.Temperature > w.Temperature

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。