SQL Group by Year

前端 未结 6 965
别那么骄傲
别那么骄傲 2021-01-07 21:09

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

6条回答
  •  情深已故
    2021-01-07 21:48

    You should add column shoptransfer.Date into group by clause.

    select CONVERT(varchar,cast(date as datetime),3)
    from shoptransfer 
    where 
    SUBSTRING(productcode, 5, 3) like '%' 
    group by CONVERT(varchar,cast(date as datetime),3)
    

提交回复
热议问题