I have a query :
select score, count(1) as \'NumStudents\' from testresults where testid = \'mytestid\' group by score order by score
Does MySQL support set-returning functions? Recent releases of PostgreSQL have a function, generate_series(start, stop)
that produces the value start
on the first row, start+1
on the second, and so on up to stop
on the stop
th row. The advantage of this is that you can put this function in a subselect in the FROM
clause and then join to it, instead of creating and populating a table and joining to that as suggested by le dorfier and Bill Karwin.