Possible Duplicate:
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….

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 where LESSON='CHEM' group by LESSON

wich :