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
  1. SELECT AVG(top_rating.min_length) AS avg_min_length,
  2.        AVG(top_rating.max_length) AS avg_max_length
  3. FROM (SELECT top.rating,
  4.        MIN(top.length) AS min_length,
  5.        MAX(top.length) AS max_length,
  6.        AVG(top.length) AS avg_length,
  7.        MIN(top.rental_rate) AS min_rental_rate,
  8.        MAX(top.rental_rate) AS max_rental_rate,
  9.        AVG(top.rental_rate) AS avg_rental_rate) AS top_rating
  10. FROM
  11.   (SELECT title,
  12.           rental_rate,
  13.           length,
  14.           rating
  15.    FROM movie
  16.    WHERE rental_rate > 2
  17.    ORDER BY length DESC
  18.    LIMIT 40) AS top
  19. GROUP BY top.rating
  20. ORDER BY avg_length;

Reply to "FROM"

Here you can reply to the paste above