I use this query to summarize the contents of the table `export_blocks`, aggregated by user and date, and save it as a new table:

```sql
CREATE TABLE export_days
SELECT user_id DATE(submitted) AS date_str,
FROM export_blocks
GROUP BY user_id, DATE(submitted)
ORDER BY user_id, submitted

```

How can I, for each `user_id` get an incremental index for the date of records for that user? The indicies should start at 1 for each user, following the ORDER BY. I.e. I'd like to generate the `date_index` of the output below using SQL:

```sql
user_id date_str   date_index
brian   2014-06-10 1
brian   2014-06-12 2
brian   2014-06-15 3
louis   2014-06-08 1
louis   2014-06-16 2
lucy    2013-11-15 1
(etc...)

```

I've been trying <https://stackoverflow.com/a/5493480/1297830> but I cannot get it to work. It stops the counters prematurely, giving too low numbers for `id_no` and `date_no`.