I have a table.
ID name col lev
1 "Rack 1" 9 7
2 "Rack 2" 6 7
3 "Rack 3" 6 7
4 "Rack 4" 7 7
I want to crate a second table from this one that uses 'col' and 'lev' number as to range. Also, 'lev' needs to be in letters.
The result should be a new tble that looks like this.
ID Name col lev
1 Rack 1 1 A
2 Rack 1 1 B
3 Rack 1 1 C
4 Rack 1 1 D
5 Rack 1 1 E
6 Rack 1 1 F
7 Rack 1 1 G
8 Rack 1 2 A
9 Rack 1 2 B
10 Rack 1 2 C
11 Rack 1 2 D
12 Rack 1 2 E
13 Rack 1 2 F
14 Rack 1 2 G
15 Rack 1 3 A
16 Rack 1 3 B
17 Rack 1 3 C
18 Rack 1 3 D
19 Rack 1 3 E
20 Rack 1 3 F
21 Rack 1 3 G
Any ideas?
You can use
generate_seriesto achieve what you're looking for. Also, create another table for converting your lev integers to text values.View on DB Fiddle
If you need an arbitrary ID column, then just add a
row_number()to your select statement.