Add first lead date to my product without breaking product rows

I have the following CTE running an explore (redshift). The idea behind it is to check product performance and it was going well and I had a line for each product, however, when tried to put the date of the first lead received into the table i stumbled upon a problem.

I only found a way of doing that through Table Calculations, but to do that i have to include the lead date into the table and that breaks my products into multiple lines. Like that:

savordelli_0-1703254926527.png

Is there another way to do this?

```
WITH products AS (
SELECT
product_table.*,
some custom columns,
some leads columns,

ROW_NUMBER() OVER (PARTITION BY product.product_id ORDER BY lead.createdat DESC) AS row_num
FROM lead table lead
INNER JOIN tables on product_id
GROUP BY each column used
)
SELECT * FROM products
```

0 2 250
2 REPLIES 2
Top Labels in this Space
Top Solution Authors