MySQL Forums
Forum List  »  General

Query to create a counter
Posted by: Björn Döhring
Date: February 27, 2017 06:05AM

I would like through a simple query within a query result a counter depending on an ID (duplicates) within an ID.

for example a table looks like that:
+--+
|ID|
+--+
|1 |
|1 |
|1 |
|2 |
|2 |
|3 |
|4 |
|4 |
|5 |
|5 |
|5 |
+--+
Desired result after the query:

+--+-------+
|ID| Zähler|
+--+-------+
|1 | 1 |
|1 | 2 |
|1 | 3 |
|2 | 1 |
|2 | 2 |
|3 | 1 |
|4 | 1 |
|4 | 2 |
|5 | 1 |
|5 | 2 |
|5 | 3 |
+--+-------+

How can I use a query to create such a counter within an ID?

Options: ReplyQuote


Subject
Written By
Posted
Query to create a counter
February 27, 2017 06:05AM
February 27, 2017 11:13AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.