I am now using Microsoft SQL, my code is:
SELECT TOP 1 [avail] FROM [table1] where [name] = \'abc\' order by [datetime] desc
I
You can use this
SELECT ISNULL(( SELECT TOP 1 [avail] FROM [table1] where [name] = 'abc' order by [datetime] desc), 0) AS [avail]