Advertisement
t7235
Oct 30th, 2023
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. необходимо добавить псевдонимы, иначе тренажер не примет
  2.  
  3. SELECT i.billing_country,
  4. MIN(i.total) AS min_total,
  5. MAX(i.total) AS max_total,
  6. AVG(i.total) AS avg_total
  7. FROM invoice AS i
  8. WHERE i.invoice_id IN
  9. (SELECT invoice_id
  10. FROM invoice_line
  11. GROUP BY invoice_id
  12. HAVING COUNT(invoice_line_id) > 5)
  13. AND i.total >
  14. (SELECT AVG(unit_price)
  15. FROM invoice_line)
  16. GROUP BY i.billing_country
  17. ORDER BY avg_total DESC, i.billing_country;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement