阅读量:0
- 查询所有电影的数量
SELECT COUNT(*) AS total_movies FROM film;
- 查询所有电影的平均租金
SELECT AVG(rental_rate) AS avg_rental_rate FROM film;
- 查询电影库存大于10的电影名称和库存量
SELECT title, inventory_id FROM film WHERE inventory_id > 10;
- 查询租借记录中每个客户借阅电影的总数量
SELECT customer_id, COUNT(*) AS total_rentals FROM rental GROUP BY customer_id;
- 查询最近一个月内租借次数最多的电影
SELECT film_id, COUNT(*) AS total_rentals FROM rental WHERE rental_date >= DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY film_id ORDER BY total_rentals DESC LIMIT 1;