SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
WITH WeeklyRentals AS ( SELECT WEEK(rental_date, 1) AS week_num, COUNT(rental_id) AS total_rentals FROM rental WHERE rental_date BETWEEN '2005-08-01' AND '2005-08-31' GROUP BY week_num HAVING total_rentals > 0 -- Убедитесь, что считаем только недели с арендой ) SELECT SUM(total_rentals) / 3.0 AS weekly_average_rentals_count -- Используем 3, так как это количество уникальных недель FROM WeeklyRentals;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear