Solved

order by int avoiding null values

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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.  …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
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…

730 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