Home > Software engineering >  Active Record Sort by 2 conditions
Active Record Sort by 2 conditions

Time:03-21

How can I sort by number first and further sort same number names by alphabet?

Example:

Score | Name
-----------
12     John
11     Paul
10     Dave
9      Adam
9      Ben
9      David

CodePudding user response:

Just use the SQL syntax for ordering by multiple columns:

order by Score, Name

CodePudding user response:

Select * from Table Order by Score , Name
  • Related