SQL Data - Return a Null record if query returns nothing
Occasionally I need to have a query return a NULL
result, instead of an empty result.
Using the MIN(fieldname)
function the query will return NULL
if nothing was found. MAX(fieldname)
works as well. Depends on what you want from your data.
SELECT
MIN(t.id)
FROM dbo.tableName t
WHERE t.unprocessed = 1