03Explorer
Technical User
I have a table with performance data
I want the data to output in a query so it is a pivot but only with the last three years (from today; so for 2018 it would display 2017, 2016, 2015).
[Code Query]TRANSFORM First(tblAssociatePerformance.Rating) AS FirstOfRating
SELECT tblAssociatePerformance.AssociateID
FROM tblAssociatePerformance
GROUP BY tblAssociatePerformance.AssociateID
PIVOT tblAssociatePerformance.Year;[/Code]
[Code Query-Output]AssociateID 2017 2016 2015
Joe Meets Expectations Meets Expectations Meets Expectations
Jan Meets Expectations Meets Expectations Meets Expectations
Mark Meets Expectations Meets Expectations Exceeds Expectations
[/code]
How (in Access SQL code) can I manipulate the Column header for year to be a.) Ordered Newest to Oldest Year(Left to Right) b.) Display ONLY last three years. I am thinking there should be a nested query as a filter 'SELECT Top 3 years...'
Thank you
Code:
aID Name Year Performance
1 Joe 2014 Meets Expectations
2 Mark 2015 Exceeds Expectations
3 Joe 2015 Meets Expectations
4 Jan 2015 Meets Expectations
5 Joe 2016 Meets Expectations
... ... ... ...
50 Joe 2017 Meets Expectations
51 Jan 2017 Meets Expectations
52 Mark 2017 Meets Expectations
I want the data to output in a query so it is a pivot but only with the last three years (from today; so for 2018 it would display 2017, 2016, 2015).
[Code Query]TRANSFORM First(tblAssociatePerformance.Rating) AS FirstOfRating
SELECT tblAssociatePerformance.AssociateID
FROM tblAssociatePerformance
GROUP BY tblAssociatePerformance.AssociateID
PIVOT tblAssociatePerformance.Year;[/Code]
[Code Query-Output]AssociateID 2017 2016 2015
Joe Meets Expectations Meets Expectations Meets Expectations
Jan Meets Expectations Meets Expectations Meets Expectations
Mark Meets Expectations Meets Expectations Exceeds Expectations
[/code]
How (in Access SQL code) can I manipulate the Column header for year to be a.) Ordered Newest to Oldest Year(Left to Right) b.) Display ONLY last three years. I am thinking there should be a nested query as a filter 'SELECT Top 3 years...'
Thank you