Home > OS >  HOW TO PRINT A TO Z ALPHABETS IN QUERY WITHOUT USING TABLE
HOW TO PRINT A TO Z ALPHABETS IN QUERY WITHOUT USING TABLE

Time:07-28

HOW TO PRINT A TO Z ALPHABETS IN QUERY WITHOUT USING TABLE

CodePudding user response:

For Oracle, here's one option:

SQL> select chr(level   64) letter
  2  from dual
  3  connect by level <= ascii('Z') - ascii('A')   1;

LETTER
----------
A
B
C
D
E
F
<snip>
X
Y
Z

26 rows selected.

SQL>

CodePudding user response:

For Postgres:

select chr(code)
from generate_series(ascii('A'), ascii('Z')) as t(code)
order by code
  • Related