sql >> Base de Datos >  >> RDS >> Mysql

cómo seleccionar el valor mínimo usando tener la palabra clave

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

o

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