mysql - group by ratio and seniority list IN SQL -



mysql - group by ratio and seniority list IN SQL -

i working on mysql, , looking solution show info grouping ratio.

i have course table contain courses id , courses ratio. have table, ask, contain askers id, , field course of study id pointing on course table (ids correspond). 1 sql query, display asks grouping ratio , rejecting other demands. demands considered seniority list.

by example, have 3 courses: first 1 allow 2 people , 2 other courses allow 1 person. in inquire table, have 3 askers (jack, joe , john) pointing on first course, (john , joe) 2 on sec , 3rd (jack , john). jack older, after john , after joe.

i see:

course id studentname ------------------------- 1 jack 1 john 2 john 3 jack

select c.courseid s.studentname course of study c bring together asks on a.courseid = c.courseid bring together pupil s on s.studentname = a.studentname bring together asks a2 on a2.courseid = c.courseid bring together pupil s2 on s2.studentname = a2.studentname , s2.seniority <= s.seniority grouping c.courseid , c.ratio , s.studentname having c.ratio >= count(*) order c.courseid , s.seniority

mysql sql

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -