This is my query.
select CONVERT(varchar, cast(date as datetime), 3)
from shoptransfer
group by year (date)
I want to group by the year pa
If you want to select both the date and the year you should not use a GROUP BY clause as it combines all of the rows with similar years into one row. If you want all of the dates with similar years together you can use an ORDER BY:
SELECT DATEPART('yyyy',date) AS Year,date
FROM shoptransfer
OR
SELECT DATEPART('yyyy',date) AS Year,date
FROM shoptransfer
ORDER BY DATEPART('yyyy',date) desc