|not sure about looping in MySQL, believe its tricky, so I'd take care of that in by building a recordset in your program code, first your gonna need each distinct ServiceID...
SELECT DISTINCT serviceid from service
put the results of that into an array..
then your gonna have to loop through each one with something like...
WHERE serviceid = frompreviousstatement
ORDER BY Qos ASC
LIMIT 0 , 1
and put each result from that into another array...