Mysql GROUP_CONCAT of first n rows || Selecting first and last values in a group || Select first and last row from group_concat when grouping sortable days
select s.id,count(e.id) as total,
substring_index(group_concat(e.id orderby e.id asc),',',5) as group_value
from students s leftjoin exams e on s.id=e.student_id
groupby s.id
orderbycount(e.id) desc
No comments:
Post a Comment