- SELECT AVG(top_rating.min_length) AS avg_min_length,
- AVG(top_rating.max_length) AS avg_max_length
- FROM (SELECT top.rating,
- MIN(top.length) AS min_length,
- MAX(top.length) AS max_length,
- AVG(top.length) AS avg_length,
- MIN(top.rental_rate) AS min_rental_rate,
- MAX(top.rental_rate) AS max_rental_rate,
- AVG(top.rental_rate) AS avg_rental_rate) AS top_rating
- FROM
- (SELECT title,
- rental_rate,
- length,
- rating
- FROM movie
- WHERE rental_rate > 2
- ORDER BY length DESC
- LIMIT 40) AS top
- GROUP BY top.rating
- ORDER BY avg_length;
FROM
From Diminutive Macaque, 3 Months ago, written in Plain Text, viewed 70 times.
This paste is a reply to inner join 1/6 from Kate
- view diff
URL http://codebin.org/view/451f7c73
Embed
Download Paste or View Raw
— Expand Paste to full width of browser