I am trying to create some sort of list of fruits. I want create a temporary column increment_value
that takes the count of how much fruit has been inserted by type.
I have this fruits table:
+----------+------------+
| fruit_id | fruit_name |
+----------+------------+
| 5 | Apple |
| 8 | Banana |
| 8 | Banana |
| 5 | Apple |
| 5 | Apple |
+----------+------------+
Desired result:
+----------+------------+-----------------+
| fruit_id | fruit_name | increment_value |
+----------+------------+-----------------+
| 5 | Apple | 1 |
| 8 | Banana | 1 |
| 8 | Banana | 2 |
| 5 | Apple | 2 |
| 5 | Apple | 3 |
+----------+------------+-----------------+
I tried with dummy table but failed: DEMO
How do I get the table I want?