Add a IF Statement before the condition
like
if (Select
Case
When
(Select Count(ID) From TaskAssignment where BookCode='CCITAY09' and Section='w01'))
=
(Select Count(ID) From TaskAssignment where BookCode='CCITAY09' and Section='w01' and Status='Completed')
Begin
Select Max(EndTime) EndTime From
(
Select EndTime From AssignedTaskReporting where BookID in
( Select ID From TaskAssignment where BookCode='CCITAY09' and Section='w01' )
and EndTime !='N/A'
union all
Select EndTime from WLATaskAssignment where BookID='CCITAY09' and Section='w01' and Status='Completed'
)v
End
else
'hlkljhlj'
END