how to select, average and sort in mysql table
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i have a table in mySql like in this picture and i want to write a query which result will group by LESSON column, and add new row which is average value of LESSON column and sum CNT column values.... for this query i use this one i use this query but it gives result like in picture 3 and i cant sort by PERC in this case select no, STUD_ID,CLASS,LESSON, AVG(PERC) as PERC,SUM(CNT) as CNT from t_lesson where LESSON='CHEM' group by CLASS union all select no,STUD_ID,CLASS,'AVERAGE' as LESSON, AVG(PERC) as PERC, SUM(CNT) as CNT from t_lesson