You need to “FEED” your pivot with only the required columns
Example
select *
from ( Select ID
,City
,State
,Year
,Dollars
From YourTable
) src
pivot (sum(Dollars) for year in ([2017], [2018], [2019])) pvt
CLICK HERE to find out more related problems solutions.