Solved

order by int avoiding null values

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

816 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

11 Experts available now in Live!

Get 1:1 Help Now