I'm using the following to create a new table (code provided by an Expert):
SELECT pi, Pres5, MAX(Pres_Start) as max_date
GROUP BY pi, Pres5;
but would like the change the column name Pres5 to MOPI in the new table. I'm not sure how to do this. I've tried changing the column name after the table has been created, using sp_RENAME but can't get that working and it would be much neater to change it when I create the table in the first place.
I'm awarding 500 points.