I am working on a MYSQL, and I am looking for a solution to show data grouping by ratio.
I have a COURSE table which contain courses id and courses ratio. I have another table, ASK, which contain askers id, and another field course id pointing on COURSE table (ids correspond). With one SQL query, I would like to display all asks grouping by ratio and rejecting other demands. Demands are considered by seniority list.
By example, I have 3 courses: the first one allow only 2 people and 2 other courses allow only one person. In the ASK table, we have 3 askers (JACK, JOE AND JOHN) pointing on first course, (JOHN AND JOE) 2 on second and third (JACK AND JOHN). JACK is the older, after its JOHN and after its JOE.
I would like to see:
course id studentName
-------------------------
1 JACK
1 JOHN
2 JOHN
3 JACK
1 Answer