------解决方案-------------------- select max(a),min(a),max(id),min(id) from t group by sj;
分太多了。
------解决方案--------------------
------解决方案-------------------- 好像有点不一样,要用分析函数来做
SQL code
select *
from
(
select t.*,row_number() over(partition by sj order by a desc ) max_rn,row_number() over(partition by sj order by a ) min_rn from t
)
where max_rn=1 or min_rn=1
------解决方案--------------------