• Got it.

    IF @MeeTellen <> 'NEE'

    BEGIN

    -- HRS VAST

    INSERT INTO @T (JAAR, WEEK, AfdelingZPT, HrsVast)

    (

    SELECTDBO.ISOyear(Begindatum) Jaar, datepart(ISO_WEEK,Begindatum) [Week], AfdelingZPT, sum(DUUR/60.0) HrsVast

    FROM DRPDATA

    WHERE LocatieCode = @IDHuis

    and AfdelingZPT = @IDAfd

    AND DBO.ISOyear(Begindatum) = @Jaar

    and OEGroep = 'zorg'

    AND NiveauZPT IN ('1','2','2+','3','4','5')

    and FlexVast = 'vast'

    and DienstGroep = 'Dag/Avond'

    --and @MeeTellen <> 'nee'

    GROUP BY DBO.ISOyear(Begindatum), datepart(ISO_WEEK,Begindatum), AfdelingZPT

    );

    .

    .

    .

    .

    END