-1

I have the following SQL statement:

select s.conclusion, t.* from trip t 
JOIN triprequirementsmapping m ON m.tripid = t.trip_id
JOIN approvalsubmission s ON s.requested = m.corporatetravelrequesturi
where s.conclusion <> 'DISCONTINUED'

The value of the s.conclusion is null for this example.

Problem

This query returns no rows, when I expect it to return one row, because s.conclusion is not DISCONTINUED.

Question

How do I do the WHERE clause to return all rows that don't have a value of DISCONTINUED?

Richard
  • 8,193
  • 28
  • 107
  • 228

1 Answers1

5

You need to explicitly deal with the NULL value:

where s.conclusion <> 'DISCONTINUED' or s.conclusion IS NULL

Postgres offers a useful operator for that situation which deals with NULL values as expected.

where s.conclusion is distinct from 'DISCONTINUED'