31 Years of Python | 48 Hour Sale Extension!!!
days
hours
minutes
seconds

Guided Project: Customers and Products Analysis Using SQL, screen 7: can't understand how correlated WHERE subquery works

Hi, I can’t understand how correlated WHERE subquery works in the guided project.
On the screen 7 there is a code that created a table with the sales per month and per customer in the month when a customer does a first purchase

This is an initial table

This is the code.

WITH 
payment_with_year_month_table AS (
SELECT *, 
       CAST(SUBSTR(paymentDate, 1,4) AS INTEGER)*100 + CAST(SUBSTR(paymentDate, 6,7) AS INTEGER) AS year_month
  FROM payments p
)
SELECT *
  FROM payment_with_year_month_table p1
 WHERE p1.customerNumber NOT IN (SELECT customerNumber
                                   FROM payment_with_year_month_table p2
                                  WHERE p2.year_month < p1.year_month)

It creates the following table

I do not understand how WHERE p2.year_month < p1.year_month works. It takes a first row of p2 table and compares it with what? How values for p1.year_month are chosen?