简体   繁体   English

选择一年制作几部电影

[英]SELECT how many movies where made in a year

I have two rows in my database, one row is for the movies, the other one is for the year a movie was made 我的数据库中有两行,一行是电影,另一行是电影制作年份

I would like to select every movies and check how many were made in a specific year, it has to be every year. 我想选择每部电影,并检查在特定年份必须制作多少部电影。

The output should look like this: 输出应如下所示:

2018 = 819
2017 = 910
2016 = 128
2015 = 539

What I tried: 我试过的

SELECT LEFT(movie,4), COUNT(year) FROM movies GROUP BY LEFT(movie,4);

but it only outputs the name of the movies 但只输出电影的名称

Thanks for reading. 谢谢阅读。

尝试这个

Select year, count(1) from movies group by year

试试这个简单的查询使用GROUP BY

Select count(*),year from movies group by year

请试试

Select year, count(movie) from movies group by year

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在多对多电影和演员关系中选择具有五个或更多演员的所有电影? - How do I select all movies with five or more actors in a many-to-many movies and actors relationship? 查询以查找今年购买了多少,对于每个艺术家 - Query to find how many purchases were made this year, For each Artist 有多少电影只属于一种类型? - How many movies belong to only one genre? 如何在电影类别为:search的电影中查询选择名称-在SEARCH之前和之后添加一些字符串 - How do I query SELECT name FROM movies WHERE category LIKE :search - with adding some string before and after SEARCH imdb dataset select 电影数量按年份计算,只有女性演员的电影 - imdb dataset select movie count according to year with movies with only female cast MySQL选择多对多的地方 - MySQL Select Where In Many to Many Laravel 5.7 - 多对多关系 - 选择具有提供的流派 ID 数组的电影 - Laravel 5.7 - Many To Many Relation - Select Movies which have the provided array of Genre IDs 无法弄清楚如何选择按特定流派分类的电影 - Can't figure out how to select movies categorized in specific genres 如何选择在mysql中发布超过2部电影的年份 - how to select years which has more than 2 movies released in mysql 如何从数据库中选择收视率最高的前10部电影? - How to select top 10 of the most rated movies from a database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM