Еще одно предложение с использованием DENSE_RANK()
:
DECLARE @FooTable TABLE
(
xDate VARCHAR(25),
xItem VARCHAR(10),
xCount INT
)
INSERT INTO @FooTable
(
xDate,
xItem,
xCount
)
VALUES
('2018-01-01', 'A', 100)
, ('2018-01-01', 'B', 200)
, ('2018-01-01', 'D', 500)
, ('2018-01-02', 'C', 200)
, ('2018-01-02', 'E', 800)
SELECT
s.*
FROM
(
SELECT
ft.xDate
, ft.xItem
, ft.xCount
--, ROW_NUMBER() OVER(PARTITION BY ft.xDate ORDER BY ft.xCount DESC) rn
, DENSE_RANK() OVER (PARTITION BY ft.xDate ORDER BY ft.xCount desc) dr
FROM @FooTable ft
)s
WHERE s.dr < 3