I collect the same similar data with different type value based on id in one table:
+------+---------------+-----------------+----------------+
| id | TransID | Amount | InsertDate |
+------+---------------+-----------------+----------------+
| 1 | 1 | 12 | 19-03-2004 |
| 2 | 2 | 9 | 20-03-2004 |
| 3 | 3 | 4 | 21-03-2004 |
| 4 | 1 | 12 | 22-03-2004 |
| 5 | 2 | 9 | 23-03-2004 |
| 6 | 3 | 4 | 24-03-2004 |
| 7 | 1 | 12 | 25-03-2004 |
+------+---------------+-----------------+----------------+
When I select the table based on the TransID of 1, I want to have a unique auto increment ID for the record based on the id of the table.
How to do this? So the result would be
+------+---------------+-----------------+----------------+---------------
| id | TransID | Amount | InsertDate | NewGeneratedID
+------+---------------+-----------------+----------------+-----------------
| 1 | 1 | 12 | 19-03-2004 | 1
| 4 | 1 | 12 | 22-03-2004 | 2
| 7 | 1 | 12 | 25-03-2004 | 3
+------+---------------+-----------------+----------------+ ---------------
AND when I select to only a specific id of the table, for example the id of 4, it will give me the NewGeneratedID of 2, not 1.
+------+---------------+-----------------+----------------+---------------
| 4 | 1 | 12 | 22-03-2004 | 2
+------+---------------+-----------------+----------------+