Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:05:50+00:00 2026-06-11T10:05:50+00:00

I have a table with 3 fields, say: roll varchar(100) marks int (10) //

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:05:51+00:00Added an answer on June 11, 2026 at 10:05 am

    Use:

    ORDER BY marks DESC, time ASC
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you have a table which stores articles, and each article can have
I have a feed table with say fields: id - unique feed id created
I have an mnesia table with fields say f1, f2, f3. Now if I
Say I have a table of products with fields regular_price and sale_price and I
Say I have a post table containing the fields post_id and parent_post_id . I
I have a lookup table say cities with fields CityId, CityName CityId CityName 1
Say I have a database table with three fields: id, content and timestamp. Entries
Let's say, I have a table objects . It has fields id , name
I have a table with 3 fields, let us say field1, field2, and field3.
Suppose the table have two fields: url(varchar), type(smallint). When the content of url is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.