Mysql
 sql >> Datenbank >  >> RDS >> Mysql

wie man den Mindestwert mit dem Schlüsselwort auswählt

select somecolumn1,somecolumn2
from stu_dept_cs 
group by somecolumn1,somecolumn2,avg
having avg = min(avg)

oder

with t1
(select rownumber() over (partition by somecolumn1,somecolumn2 
    order by somecolumn1,somecolumn2,avg asc) as rownum
from stu_dept_cs )
select * from t1 where rownum=1