• Sergiy (5/31/2016)


    jc85 (5/31/2016)


    WHERE month(b.start_time) = @Loc_Month

    AND year(b.start_time) = @Loc_Year

    Is there any other way to avoid using function in WHERE clause in this scenario?

    It doesn't have huge impact on query speed but as pointed out earlier, it is not a good practice.

    Yes, of course.

    Build @StartDate and @EndDate out of @Loc_Year and @Loc_Month and... You know what to do then.

    Sorry for not being clear enough, this is meant to use as a monthly report so I would need to do a month and year comparison.

    User will select a single date and it will be passed as @Date.

    My idea is to declare 2 local variables @Loc_Month and @Loc_Year to grab month and year from @Date and then use them to do comparison.

    Date (start_time)--report_item----EN (lang)---BM (lang)

    2015-01-------Noisy----------------------3------------- 0

    2015-01-------No Dial Tone-------------6--------------2

    2015-02-------Noisy----------------------1--------------2

    2015-02-------No Dial Tone-------------0------------- 7