• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • 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

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

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