I have the following table
| order_id | created_at | customer_id |
|---|---|---|
| 1 | 2020-01-02 | 11 |
| 2 | 2020-02-03 | 12 |
| 3 | 2020-02-03 | 11 |
I would like to add a column "customer_orders_count" that will assign the number of orders that a customer passed to each transaction, ie obtain this table :
| order_id | created_at | customer_id | customer_orders_count |
|---|---|---|---|
| 1 | 2020-01-02 | 11 | 1 |
| 2 | 2020-02-03 | 12 | 1 |
| 2 | 2020-02-03 | 11 | 2 |
My problem it's I can't find how to calculated a local "customer_orders_count" dependind on each order, I only managed to add a column with the global "customer_orders_count" and for example for the first row order_id=1 I'll get customer_orders_count=2 whereas I'll like to be 1.
Does anyone has and idea ?
