SQLite Forum

Row count
Login
```
/* Create the table ... since you have not scripted it!! */
DROP TABLE IF EXISTS tmp;
	CREATE TABLE tmp (
		idx INT,
		data VARCHAR(1)
		);
/* Populate the table */
INSERT INTO tmp (
	idx,
	data
	)
VALUES (1,'a'),
	(2,'a'),
	(3,'a'),
	(4,'b'),
	(5,'b'),
	(6,'b'),
	(7,'b'),
	(8,'b'),
	(9,'c'),
	(10,'c');
/* Here's one solution */
SELECT a.idx,
	a.data,
	(b.id || ' /' || c.cnt) AS cnt /* Count is a reserved word */
FROM (
	tmp a INNER JOIN (
		SELECT (
				row_number() OVER (
					PARTITION BY data ORDER BY idx ASC
					)
				) AS id,
			*
		FROM tmp
		) b ON a.idx = b.idx
	)
INNER JOIN (
	SELECT data,
		count(*) AS cnt
	FROM tmp
	GROUP BY data
	) c ON a.data = c.data;
```