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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:07:33+00:00 2026-05-12T06:07:33+00:00

I have created a table. In one field, I have a priority of that

  • 0

I have created a table. In one field, I have a priority of that record (between 1-9).
I didn’t set priority for all the records, so for some records, it will remain null.

When displaying these records in my HTML page, I just check those priorities — if the priority exists, then I will display as it is, if it’s null, then I will display it as the lowest priority of ’10’ (just for display).

The problem occurs while sorting the table. If I try to sort(DESC) the table, it displays the 10 in the first row and later continues perfectly (1,2,….).

How to solve this?

Is it possible to display the priorities first and later continue with the null values?

  • 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-12T06:07:34+00:00Added an answer on May 12, 2026 at 6:07 am

    There are a number of ways to solve it.

    1/ Change the data so that 10 is actually in the table (rather than NULL):

    update table TBL set FLD = 10 where FLD is null;
    

    2/ Modify your query to return different values for NULL:

    select FLD1, FLD2, case where FLD3 is null then 10 else FLD3 end from ...
    

    3/ Create a view to do option 2 above automagically.

    I’d tend to go for option 1 since it’s likely to be the most efficient.

    SQL does not specify how NULLs are sorted (although I think it specifies they must be adjacent) – that means they could be at the beginning or end (or possibly in the middle though I’ve never seen that happen).

    The reason I bring up the efficiency aspect is that per-row functions do not scale well. As the table gets bigger, you’ll find that converting NULLs into 10 every time you select will be very expensive.

    It’s far better to bite the bullet and just set them to 10 in the database. This will allow the DBMS to optimize queries better. And, if you ever need to use 10 for another real priority level, just change all the current 10s to 11s (or 9999s) before you start.

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

Sidebar

Related Questions

I have a table that has no primary key, and one cannot be created
I have one table that I'm using to store all access requests for a
I have created a simple search field that will ajax in relevant search results
i have created a table for educational information .one of it's field is for
I have created one database and one table user in that while running my
I have created one table using the below command: create table Table1( Id int
I have created one jTable. I want to display the data into table from
i have one question about jquery ajax().. I created a table grid and there
I have created a table in Visual Studio. That table has two columns. First
I have created a database and a table. I have also created all the

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.