SELECT plan, begindate FROM mytable WHERE begindate IN ( SELECT TOP 2 begindate FROM mytable ORDER BY begindate DESC) UNION ALL SELECT MAX(plan) + 1, CAST(Null AS D) FROM mytable ORDER BY begindate DESC>Oops, sorry. I know the problem of not being able to use the order by in the first select. Any ideas on how to return the correct results?