Solved

order by int avoiding null values

Posted on 2010-08-25
4
307 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 42

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 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

13 Experts available now in Live!

Get 1:1 Help Now