SQL- Ensuring query does not include results where a certain column in null?

Below is the query I am using in order to check how many rows in my table have a date older than 01/01/2015 (TIMESTAMP).

How can I alter this query to ensure that it does not include any results where the DATE_INSERTED column is null?

Also, if this is not the most efficient way to check for this condition, I would appreciate alternatives.

Current query:

SELECT COUNT(*)
FROM TABLE_NAME
WHERE DATE_INSERTED NOT BETWEEN '01-JAN-2015 00.00.00.00' AND '18-JAN-2016 00.00.00.00';

Answers


You want to use a is not null Here's your query updated:

SELECT COUNT(*)
FROM TABLE_NAME
WHERE DATE_INSERTED
    NOT BETWEEN '01-JAN-2015 00.00.00.00' AND '18-JAN-2016 00.00.00.00'
    AND DATE_INSERTED is not null;

New line spacing is optional. Although it may look misleading by having: between param1 and param2 and column is not null... the first where condition you set (between) only takes two parameters, so the next AND is treated as default. Whereas the first is the separation between the first and second BETWEEN params.


Need Your Help

Pass code using POST method

php html forms post

I made a form that receives source code that can be written in C/C++/Python/Java/Ruby

Change user timeline summary text

twitter header widget customization tweets

I'm using the Twitter User Timeline widget from here. I want to change the summary that reads "Tweets" in the header, to say "News". How do I do that?