order by date asc putting blank dates on the bottom

Hi,

I'm doing a query where I want to sort the data by the column "shipdate".  The most recent ship dates should be on top.  Simple enough using order by date ASC.

Similar to this...

SELECT
name, dealer, orderid, shipdate
FROM tblOrders
ORDER BY shipdate ASC

HOWEVER, some of the shipdates are null and/or empty.  These ship dates are returning on the top of the returned query.  I want the rows with no ship date to appear on the BOTTOM of the query, after the rows that have a ship date in the proper order.

How can I do this?


benjamintrAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
snoyes_jwConnect With a Mentor Commented:
ORDER BY shipdate IS NULL OR shipdate = '', shipdate
0
 
benjamintrAuthor Commented:
That works!  Could you provide a quick explanation for me of what's going on?
0
 
snoyes_jwCommented:
IS NULL return 0 if the value is not null, 1 if it is. 0 sorts before 1, so we have all not null and not empty values before all null or empty values.  Then within those two groups, we sort by shipdate.
0
All Courses

From novice to tech pro — start learning today.