I improved on your query.
Pls try the below query.
IF(@Sal=null,null,@Sal) as MySalary
(select @Sal:=(select distinct (Salary) as SecondHighestSalary from Employee order by Salary Desc limit 1,1)) variables
As you can notice there were 3 issues in ur query.
namely you used asc instead of desc.
Secondly if no return is returned you are not returning null (I think so).
Thirdly, using distinct you will pick only single value if many people are contenders for the second largest salary.
Sure you can use LIMIT but you need to give your result an alias "SecondHighestSalary" to pass the system.
Check my accepted answer