I am now using Microsoft SQL, my code is:
SELECT TOP 1
[avail]
FROM [table1]
where [name] = \'abc\'
order by [datetime] desc
I
Try to use COALESCE. It selects the data from the first argument that has a nonnull value. If avail is not null, return [avale], otherwise return "Not Found"
SELECT COALESCE(avail, 'Not Found')
FROM table1
WHERE name = 'abc'
ORDER BY datetime desc
You can read about COALESCE in https://docs.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql