--方法一:直接使用表自身连接 select A.Id from Weather A join Weather B on A.RecordDate = B.RecordDate where A.Temperature > B.Temperature
--方法二:使用偏移分析函数 根据日期(Date类型)排序(id和日期可能不是对应的) selectidfrom (selectid,Temperature,lag(Temperature,1,null)over(orderby RecordDate) last_Temperature, RecordDate,lag(RecordDate,1,null)over(orderby RecordDate) last_RecordDate from Weather) A where A.Temperature>A.last_Temperature and A.last_RecordDate=A.RecordDate