Introduction
EARLIER helps you compare values in the current row with values in previous rows. It solves the problem of calculating values that depend on other rows in the same table, like ranking or running totals.
When you want to calculate a rank of sales for each product compared to others in the same category.
When you need to find the previous date's sales amount for each row in a sales table.
When you want to count how many times a customer bought a product before the current purchase.
When you want to create a running total that sums values up to the current row.
When you want to compare each row's value to the maximum value in the same group.