Thread: group number
Thank you very much for your attention.
I'm facing a mental block to achieve this in a performant manner:
I'm facing a mental block to achieve this in a performant manner:
Input:
a a
b
c
c
c
d
Desired output:
a 1
a 1
b 2
c 3
c 3
c 3
d 4
Any suggestions? Have a good day (night, afternoon or evening) and greetings from México City.
Hello
postgres=# select v, dense_rank() over(order by v) from unnest('{a,a,b,c,c,c,d}'::varchar[]) g(v);
v | dense_rank
---+------------
a | 1
a | 1
b | 2
c | 3
c | 3
c | 3
d | 4
(7 rows)
Regardspostgres=# select v, dense_rank() over(order by v) from unnest('{a,a,b,c,c,c,d}'::varchar[]) g(v);
v | dense_rank
---+------------
a | 1
a | 1
b | 2
c | 3
c | 3
c | 3
d | 4
(7 rows)
2014-05-09 22:15 GMT+02:00 Rene Romero Benavides <rene.romero.b@gmail.com>:
Thank you very much for your attention.
I'm facing a mental block to achieve this in a performant manner:Input:aabcccdDesired output:a 1a 1b 2c 3c 3c 3d 4Any suggestions? Have a good day (night, afternoon or evening) and greetings from México City.