查询最新的3条数据,总和,最小值,有判定条件

发布时间:2023年12月17日

select * from (SELECT *,MIN(huanshoulv) as minh,min(zhandifu) as minz ,sum(zhandifu) as sumz
?? ??? ??? ??? ?FROM (
?? ??? ??? ??? ??? ?SELECT *,
?? ??? ??? ??? ??? ??? ??? ??? ? ROW_NUMBER() OVER (PARTITION BY code ORDER BY date desc) AS row_num
?? ??? ??? ??? ??? ?FROM stock
?? ??? ??? ?) AS sub_query WHERE row_num <= 3 ?GROUP BY code) as hh WHERE ?minh >=10 and minz >=0 and sumz<10

文章来源:https://blog.csdn.net/zhuixunhebe1/article/details/135049390
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。