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 7445433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:49:10+00:00 2026-05-29T11:49:10+00:00

Hi im trying to order domain data using their status. As you might know,

  • 0

Hi im trying to order domain data using their status. As you might know, domain status DOM_EXP or DOM_DAKT applies before domain hits DOM_HELD therefore i dont care whitch one of this status has a domain before it became DOM_HELD

How can i order this data? Using select provided below i only achieve that DOM_DAKT is behing DOM_EXP but i want it to be somewhere in between, ordered by exp_date

SELECT domain_id, status, exp_date 
FROM domains 
ORDER BY 
field (status, 'DOM_DEL', 'DOM_HELD', 'DOM_EXP', 'DOM_DAKT'), 
exp_date ASC;

+-----------+----------+---------------------+
| domain_id | status   | exp_date            |
+-----------+----------+---------------------+
|         2 | DOM_DEL  | 2012-02-02 10:47:33 |
|         4 | DOM_HELD | 2012-02-02 10:47:38 |
|         5 | DOM_HELD | 2012-02-02 10:47:40 |
|         7 | DOM_HELD | 2012-02-02 10:47:44 |
|         1 | DOM_EXP  | 2012-02-02 10:47:27 |
|         3 | DOM_EXP  | 2012-02-02 10:47:35 |
|         6 | DOM_EXP  | 2012-02-02 10:47:42 |
|        54 | DOM_DAKT | 2012-02-02 10:47:39 |
+-----------+----------+---------------------+

the result have to be like this

+-----------+----------+---------------------+
| domain_id | status   | exp_date            |
+-----------+----------+---------------------+
|         2 | DOM_DEL  | 2012-02-02 10:47:33 |
|         4 | DOM_HELD | 2012-02-02 10:47:38 |
|         5 | DOM_HELD | 2012-02-02 10:47:40 |
|         7 | DOM_HELD | 2012-02-02 10:47:44 |
|         1 | DOM_EXP  | 2012-02-02 10:47:27 |
|         3 | DOM_EXP  | 2012-02-02 10:47:35 |
|        54 | DOM_DAKT | 2012-02-02 10:47:39 |
|         6 | DOM_EXP  | 2012-02-02 10:47:42 |
+-----------+----------+---------------------+
  • 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-05-29T11:49:13+00:00Added an answer on May 29, 2026 at 11:49 am

    Order first by “rank” of status where DOM_EXP and DOM_DAKT are considered to be of equal rank. Then order by EXP_DATE within each “rank” of status

    SELECT domain_id, status, exp_date 
    FROM domains 
    ORDER BY CASE WHEN status = 'DOM_DEL'  THEN 1
                  WHEN status = 'DOM_HELD' THEN 2
                  WHEN status = 'DOM_EXP'  THEN 3
                  WHEN status = 'DOM_DAKT' THEN 3 -- EXP and DAKT are "of equal rank"
    END,
    EXP_DATE
    

    Look at the CASE expression as a mapping status => ordering rank

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

Sidebar

Related Questions

I'm trying to use the DataAnnotationsModelBinder in order to use data annotations for server-side
Using Hibernate, I am trying to implement a one-to-one relationship between one fixed domain
I'm trying order a Linq to NHibernate query by the sum of it's children.
I'm trying to order items based on an attribute value: <xsl:apply-templates select=Question> <xsl:sort order=ascending
I'm trying to order the results of the get_list_or_404 method get_list_or_404(...).order_by('name') doesn't seem to
I have a strange problem, I am trying to order the output of a
I am trying to set up my tab order on the html side of
I'm trying to test an Order entity method called AddItem and I'm trying to
So i am trying to do this Order.find :all, :conditions => org = 'test
I am trying to have the collection of order IDs be used in my

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.