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

  • Home
  • SEARCH
  • 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 8622349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:02:00+00:00 2026-06-12T07:02:00+00:00

I have a data set like this: boolean name value 0 Text10 20 1

  • 0

I have a data set like this:

boolean name    value
0       Text10  20
1       Text1   8
0       Text4   46
1       Text9   84
1       Text5   66
0       Text2   35
0       Text9   2
1       Text6   55

Ordering by the boolean column will split the data in two sections that I want to order according to a different parameter each: The ones with boolean = 1 are ordered by value, and the rest are ordered by name, like this:

boolean name    value
1       Text1   8     # --> 1s are ordered by value
1       Text6   55
1       Text5   66
1       Text9   84
0       Text2   35    # --> 0s are ordered by name
0       Text4   46
0       Text9   2
0       Text10  20

Note: We need this to work in MySQL 4.1.11. =D

  • 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-12T07:02:01+00:00Added an answer on June 12, 2026 at 7:02 am

    Notice that it can be done with multiple parts of order by that are ‘activated’ as needed.
    You can check this sqlfiddle

    select * from yourtable
    order by 
      boolean desc, 
      case when boolean = 0 then value else null end, -- ´else null´ is redundant
      case when boolean = 1 then name  else null end  -- but is here to clarify
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set up a php script to receive url data like this: http://giffgaff.liamwli.co.uk/?name=liamwli
I have a set of data that is structured like this: ItemA.GroupA ItemB.GroupA ItemC.GroupB
I have a data set that looks like this: foo,R foo,Y bar,C foo,R baz,Y
We have a small data set and would like to search through it in
I have a data set that that I would like to call in a
I have a large real 1-d data set called r. I would like plot:
I have a 2D distribution of a data set, and I would like to
I have several complex data structures like Map< A, Set< B > > Set<
I have a selection of a huge set of data and I would like
I have set a background on the data-role=page element like so <div data-role=page style=background:

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.