I only want to get dates from the current year, and the year previous. So if it’s 2011, I get dates in 2011 and dates in 2010. If it’s 2012, I get dates in 2012 and 2011.
SELECT
DISTINCT DATEPART(yyyy, date ) as arc_year
FROM
dbo.sports
WHERE
team_id = '".$id."'
ORDER BY
DATEPART(yyyy, date ) DESC
Thanks in advance for any help
You want to avoid using a function on the column itself so an index can be used.