• It is possible for a CASE block to change the number of rows returned by SELECT with DISTINCT.

    Find a filter (a WHERE clause) which returns only rows which you think are affected, and test them using something like this:

    SELECT --DISTINCT

    cs.SITE,

    cv.accepted,

    cv.StepNo,

    ci.plannedinstalldt,

    CASE

    WHEN cv.accepted = 1 AND cv.StepNo = 1 then 'Y'

    ELSE CONVERT(varchar,[dbo].[fn_Get_WorkingDays] (ci.plannedinstalldt, -17))

    END

    FROM dbo.Cy_SiteSurvey AS cs WITH (nolock)

    INNER JOIN dbo.Cy_Visit_Checklist AS cv WITH (nolock)

    ON cv.SysSiteID = cs.SysSiteID

    WHERE whatever

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden