Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Need to Select rows with null values in one column first

ti3rFeb 8 2013 — edited Feb 8 2013
I have a table for advertising leads where the Last_Mailed_Date is often null, meaning the individual has never been sent advertising. If I query for leads that have never been mailed (is null) or who have not been mailed within 60 days, it always returns the is null rows last, so depending on number I request, I may never get the "is null" records at all. We want to pull the "is null" rows first because they have never received advertising from us before. I can't find any way to change the order of how the records are selected. Bottom line, I want to pull records with the null values first, then if I need more records, pull with the specified date requirements for last mailed.

select *
from T3_LEADS
WHERE
Last_Mailed_Date IS NULL OR (SYSDATE - Last_Mailed_Date) > 60)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 8 2013
Added on Feb 8 2013
5 comments
816 views