• ;WITH cte (ProductId,Pos) AS (

    SELECT ProductId,

    RANK() OVER(PARTITION BY SaleYear,SaleWeek ORDER BY Quantity DESC)

    FROM SalesData)

    SELECT ProductId,SUM(1-SIGN(Pos-1))

    FROM cte

    GROUP BY ProductId

    Far away is close at hand in the images of elsewhere.
    Anon.