I have a table with 3 fields, say:
roll varchar(100)
marks int (10) // can be 0 5 or 10
time anyTimeFormat
//time stores the time of passing the exam.
What I need to do is to sort in ascending order, the time of completion, which I am able to do by
ORDER by time ASC
However, I need to sort in ascending order, and at the same time, group records, based on marks, i.e. those who have scored 10 and were the first to complete, and so on.
I tried GROUP BY, but know that it won’t work. Any help on this is welcomed.
NOTE: I use mysql. PHP is the front end.
Sample Data:
roll marks time
1 10 2012-09-07 15:03:39
2 10 2012-09-07 15:03:42
3 10 2012-09-07 15:03:17
4 10 2012-09-07 15:03:20
5 5 2012-09-07 15:03:11
Expected Output::
// I want those with 10 marks to be displayed first.
roll marks time
1 10 2012-09-07 15:03:17
2 10 2012-09-07 15:03:20
3 10 2012-09-07 15:03:39
4 10 2012-09-07 15:03:42
5 5 2012-09-07 15:03:11
Use:
Or in other words, you sort on marks because you want the highest marks first, then for equivalent marks, sort by time in order to show first completers first.