SELECT NOT NULL values without WHERE clause

30,653

Solution 1

no, there is no way, if you need to filter stuff out you need a WHERE clause. That said, you can change the values returned from null to something else by using ISNULL or COALESCE

Solution 2

Are you looking for COALESCE?

i.e

SELECT COALESCE(HasBananas, 'No') FROM Sometable
Share:
30,653
Hélder Gonçalves
Author by

Hélder Gonçalves

Software Engineer with interest in .Net, C# and PL/SQL.

Updated on December 07, 2020

Comments

  • Hélder Gonçalves
    Hélder Gonçalves over 3 years

    Is there a way to select not null values without a where clause? i know it can be done like this

    SELECT X, Y, Z
    FROM T
    WHERE X IS NOT NULL
    

    but Im wondering if there is a way to put the null 'filter' in the select clause without using the where

    maybe something like this?

    SELECT NOT_NULL(X), Y, Z
    FROM T
    

    Ty