MegaSoft (Egypt) interview question

sql queries and grouping ,sorting