Untitled

From Scorching Cockroach, 9 Months ago, written in Plain Text, viewed 195 times.
URL http://codebin.org/view/bfd43ce6 Embed
Download Paste or View Raw
  1. SELECT billing_country,
  2.        MIN(total) AS min_total,
  3.        MAX(total) AS max_total,
  4.        AVG(total) AS avg_total
  5. FROM invoice
  6. WHERE invoice_id IN (
  7.       --заказы, которые включают больше 5 треков
  8.       SELECT invoice_id
  9.       FROM invoice_line as il
  10.       LEFT JOIN track AS t ON il.track_id = t.track_id
  11.       GROUP BY invoice_id
  12.       HAVING COUNT(t.track_id) > 5
  13.       )
  14.       AND total > (
  15.       -- стоимость заказа превышает среднюю иену одного трека
  16.       SELECT AVG(unit_price)
  17.       FROM invoice_line AS il2
  18.       )
  19. GROUP BY billing_country
  20. ORDER BY avg_total DESC

Replies to Untitled rss

Title Name Language When
Re: Untitled Innocent Duck text 8 Months ago.

Reply to "Untitled"

Here you can reply to the paste above