SELECT DISTINCT Vard.ApplicationDetailID, Vard.ApplicationNumber
FROM App.Vw_ApplicationDetails_Light Vard
    INNER JOIN App.ApplicationLicences Al ON Al.ApplicationDetailID = Vard.ApplicationDetailID
    INNER JOIN App.ApplicationLicenceRouteDetails Ard ON Al.ApplicationLicenceID = Ard.ApplicationLicenceID
    INNER JOIN Verified.Routes R ON Ard.VerifiedRouteID = R.RouteID
WHERE (CASE
           WHEN ISNULL(@SearchText, '') <> '' THEN
    (CASE
         WHEN Vard.ApplicationNumber LIKE '%' + @SearchText + '%' THEN
             1
         ELSE
             0
     END
    )
           ELSE
               1
       END
      ) = 1
ORDER BY Vard.ApplicationNumber ASC;