相关子查询,oracle sql

Correlated Subquery, oracle sql

我正在做作业,但我无法解决这个问题。谁能帮帮我吗?这个神谕 Sql

显示每张高于供应商平均发票金额的发票金额。 您必须使用相关子查询。

我试过了,但我没有那么接近。我的代码是:

    SELECT vendor_id, invoice_number, invoice_total
FROM ap.invoices
WHERE invoice_total  >  (SELECT AVG(invoice_total) 
                     FROM ap.invoices
                     where invoice_id=invoice_id
                     )
ORDER BY vendor_id; 

结果 table 应该与这张图片匹配: https://i.stack.imgur.com/w9D6i.png

为外部查询使用别名 table,并关联 vendor_id 字段:

SELECT vendor_id, invoice_number, invoice_total
FROM ap.invoices i
WHERE invoice_total  >  (
    SELECT AVG(invoice_total) 
    FROM ap.invoices v
    where v.vendor_id = i.vendor_id
)
ORDER BY vendor_id;