Skip to content
Advertisement

Add Sequential Letter column to table

In C I can switch between int and char to build a list of sequential integers and then convert them to ASCII characters that will be sequential according to the alphabet.

Is there a way to do this in postgres to get a column with row values “A”,”B”,”C” etc…?

the only way I can think of would be to start with a SERIAL column of ints and then write a CASE to set each row individually. The Tables big enough that it would be much preferred to do this automatically somehow.

Advertisement

Answer

Take a look here: Calculate MS Excel column name from its number in PostgreSQL

Usage:

Result:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement