Finding the decade with largest records, SQL Server

前端 未结 4 1029
我寻月下人不归
我寻月下人不归 2021-01-06 17:13

I have the following db diagram :

I want to find the decade (for example 1990 to 2000) that has the most number of movies. Actually it only deals with "

4条回答
  •  长情又很酷
    2021-01-06 17:33

    select substring(cast([year] as varchar), 1, 3) as Decade,
    Count(1) [Count]
    from Movies
    group by substring(cast([year] as varchar), 1, 3)
    order by 2 desc
    

提交回复
热议问题