I'm not sure the OP has clarified the actual requirement, or perhaps I've not had enough coffee this morning
compare data from this year to data from last year and data from two years ago
I don't want to do between 01/01/2023 and 12/31/2023
So this year we are in January a few days data - to be compared with the whole of last year and the whole of the year before? Maybe, but doesn't make much sense.
So by this year, does the OP mean last year and the two years prior to that? Or does it mean year to date this year and the equivalent period for the previous two years. Or maybe something else?
Either way, both solutions proposed are for just one year, not 3.
I would also think since this is for a comparison, the query would be a crosstab - for which the criteria can be designed to make use of indexing along the lines of ebs17's suggestion, whilst the column headings are more a presentation issue per xps35's suggestion - i.e. a bit like WHERE v HAVING in an aggregate query.