Re: How to make the generate_series to generate the letter series? - Mailing list pgsql-general

From Ian Lawrence Barwick
Subject Re: How to make the generate_series to generate the letter series?
Date
Msg-id CAB8KJ=hNxXc9dz0daV_P7pxu7yz4UBJ8CMSk7_aB9Cdc8DMHjA@mail.gmail.com
Whole thread Raw
In response to How to make the generate_series to generate the letter series?  ("Wen Yi" <896634148@qq.com>)
Responses Re: How to make the generate_series to generate the letter series?  (Bruce Momjian <bruce@momjian.us>)
List pgsql-general
2023年5月29日(月) 12:39 Wen Yi <896634148@qq.com>:
>
> Hi team,
> when I study the generate_series function, I found that it can not only generate the number series but also can
generatethe date series.(ref: https://www.postgresql.org/docs/current/functions-srf.html) 
> That means I can make the generate_series to generate the letter series.
>
> So I try this command (I guess I can follow the ascil code rule to complete this work):
>
> # SELECT * FROM generate_series('a'::int, 'z'::int, 1);
>
> But the postgres reply me a error, because the 'a' can't translate into 'integer' type.
>
> Can someone provide me a better solution?
> Thanks in advance!

SELECT chr(x + 96) FROM generate_series(1, 26) x

Regards

Ian Barwick



pgsql-general by date:

Previous
From: "Wen Yi"
Date:
Subject: How to make the generate_series to generate the letter series?
Next
From: Albert Praveen
Date:
Subject: SSPI authentication failed for user "xxx"