Mikas answer is the correct one but probably not what you wanted.
There's a slight problem though, you have stated in your tags that you're using SQL Server 2008, while in the subject line it says Oracle.
And normally for Oracle you'd use the
NVL()
function, but for SQL Server the same functionality would be achieved with
ISNULL()
.
So to be generic I will answer with
COALESCE()
.
select COALESCE(id,0) from table where phno=7777
But please do consider doing it the proper way instead, it might make a big difference in the future when you need to refactor the code you're writing at the moment