Solved

order by int avoiding null values

Posted on 2010-08-25
4
308 Views
Last Modified: 2013-12-13
Hi

i am ordering my query by seq and seq is integer ..
my problem is that the order starts with null values how i can avoid null values to be in the first
the order must start with values asc and the null values will be all in the last as they have no values
Regards
A.S
0
Comment
Question by:asaidi
  • 2
4 Comments
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33521910
it will be like

select * from table where column1 is not null order by column1 asc
0
 

Author Comment

by:asaidi
ID: 33521989
Hi rdonline1

thanks but i want to display all the data not only the not null..
0
 
LVL 11

Accepted Solution

by:
Rajesh Dalmia earned 250 total points
ID: 33522016
0
 
LVL 43

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 250 total points
ID: 33522018
Hi asaidi,

Couple of ways you can do this.



//Method 1

SELECT seq FROM ordersTable ORDER BY ISNULL(seq), seq ASC;



//Method 2

SELECT seq FROM ordersTable ORDER BY -seq DESC;

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now