Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

order by int avoiding null values

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
asaidi
Asked:
asaidi
  • 2
2 Solutions
 
Rajesh DalmiaCommented:
it will be like

select * from table where column1 is not null order by column1 asc
0
 
asaidiAuthor Commented:
Hi rdonline1

thanks but i want to display all the data not only the not null..
0
 
Rajesh DalmiaCommented:
0
 
Chris StanyonCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now