WHERE somecol IS NULL OR somecol < 18

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SET STATISTICS TIME ON;
SET STATISTICS IO ON;

SELECT COUNT(*)
FROM Posts
WHERE FavoriteCount < 18
OR FavoriteCount IS NULL;

SELECT SUM(Records)
FROM 
(
    SELECT 1
    FROM Posts
    WHERE FavoriteCount < 18

    UNION ALL

    SELECT 1
    FROM Posts
    WHERE FavoriteCount IS NULL
) x (Records);

SELECT
    (SELECT COUNT(*) FROM Posts) -
    (SELECT COUNT(*) FROM Posts WHERE FavoriteCount >= 18);

SELECT COUNT(*)
     - COUNT(CASE WHEN FavoriteCount >= 18 THEN 1 END)
FROM Posts

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results