Questions about correlated subqueries

HI

i am learning SQL with Mosh now.

for the course : Correlated Subqueries, there is one making me confused.

requirements:
–Get invoices that are larger than the
– Client’s average invoice amount.

the coding:
USE sql_invoicing;
select *
from invoices i
where invoice_total > (
select AVG(invoice_total)
from invoices
where client_id = i.client_id

My question:
How to understand the last line? why shall give alliance without connecting two tables?

By the way
is there any living exchange chatting group recommend?

thank you very much.

BR
Jingni

I don’t really understand the second part of your question but client_id = i.client_id says that we only want to include rows in the inner query that have the same client_id as the row in the outer query.

thank you SAM.

the second question is: is there any group chat, like whatsapp to discuss questions about the course?