order by one column, But put a specific content at the end


I have multiple columns. Two of them are:

Group (numeric, not unique) Name (string, not unique)

I would need to order by Group descending, BUT, if the value "Name" equals "Empty" i should be displayed at the end of the Group...

Group Name 1020 test1 1020 test2 1020 test3 1020 EMPTY <-- end of Group 1020 1020 EMPTY <-- end of Group 1020 3040 test6 3040 test7 3540 test8 3540 EMPTY <-- end of Group 3540 15060 test9 15060 EMPTY <-- end of Group 15060

How can this be done with a mysql query?


In MySQL, expressions like Name = 'EMPTY' have the value 1 if true and 0 if false.

So you can use

ORDER BY Group, Name = 'EMPTY', Name

to get all the not-EMPTY values first, then all the EMPTY ones.


  • Linq distinct based on two columns
  • How to test labels in QTP
  • How to sort things out in ListView?
  • How to fail Phing without triggering backtrace
  • Python find continuous interesctions of intervals
  • Linq Full Outer Join on Two Objects
  • Many to many relationship core data query for specific collection
  • How to get the index of element in the List in c#
  • How do you SELECT several columns with one distinct column
  • JPA CDI Injecting DAO into an Entity
  • Sum data table columns using linq
  • Rails AREL .where statement
  • Disable/remove close icon on Kendo Grid's default group column
  • css background images not always displayed
  • How to name a 'group' check box in Adobe Reader when wanting to fill form by FDF / XFDF
  • Is there any way to use wpdb prepare statements for array implode(' OR ', $myArray)?
  • SF2 Functional tests : “Resetting the container is not allowed when a scope is active”
  • You tube videos are not playing
  • SQL - Select lowest values with group by and order by?
  • Flex items with same property values are rendering in different sizes
  • How to load more than one div at a time
  • Doctrine2 bulk import try to work with another entity
  • Linq Merge lists
  • cygwin cannot exec 'git-add--interactive' permission denied
  • Query to find the duplicates between the name and number in table
  • Grails calculated field in SQL
  • AJAX Html Editor Extender upload image appearing blank
  • Jackson Parser: ignore deserializing for type mismatch
  • Time complexity of a program which involves multiple variables
  • Custom Tabgroup Appcelerator
  • How to use remove-erase idiom for removing empty vectors in a vector?
  • Django: Count of Group Elements
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Linq Objects Group By & Sum
  • Why is an OPTIONS request sent to the server?
  • Read text file and split every line in MSBuild
  • Window Size for Mac application
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • embed rChart in Markdown