Advertisement
This is comment for paste
Подзапросы в WHERE, задача 3
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- необходимо добавить псевдонимы, иначе тренажер не примет
- SELECT i.billing_country,
- MIN(i.total) AS min_total,
- MAX(i.total) AS max_total,
- AVG(i.total) AS avg_total
- FROM invoice AS i
- WHERE i.invoice_id IN
- (SELECT invoice_id
- FROM invoice_line
- GROUP BY invoice_id
- HAVING COUNT(invoice_line_id) > 5)
- AND i.total >
- (SELECT AVG(unit_price)
- FROM invoice_line)
- GROUP BY i.billing_country
- ORDER BY avg_total DESC, i.billing_country;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement