@O.Jones is spot on with the remark about tie values.
Those can easily lead to unexpected results, especially returning multiple result rows for a year.
One way to avoid this is to be very clear about what record should be returned, i.e. you may want the first entry of every year when sorted by profit. The next entries might have the same profit value, but should not be returned.
In SQL this can look like this:
WITH _profits_in_years
(YEAR, profit) as
(SELECT 1999 AS YEAR, 200 AS Profit FROM dummy UNION ALL
SELECT 1999 AS YEAR, 50 AS Profit FROM dummy UNION ALL
SELECT 2000 AS YEAR, 100 AS Profit FROM dummy UNION ALL
SELECT 2001 AS YEAR, 100 AS Profit FROM dummy UNION ALL
SELECT 2002 AS YEAR, 200 AS Profit FROM dummy UNION ALL
SELECT 2002 AS YEAR, 200 AS Profit FROM dummy UNION ALL
SELECT 2003 AS YEAR, NULL AS Profit FROM dummy
)
SELECT DISTINCT
YEAR,
FIRST_VALUE(Profit) OVER
(PARTITION BY YEAR
ORDER BY PROFIT DESC NULLS LAST)
FROM
_profits_in_years