Using a query result as title of a column
Posted: Sat Jun 23, 2018 6:52 pm
I'd like to use the data coming from a query as column name.
Suppose I have two tables:
This is a pseudo-SQL query (giving a syntax error):
The result I'd like to get is the value foo as header of the column:
How can I obtain this?
I'm using HSQLDB version 1.8.
Suppose I have two tables:
Code: Select all
my_table
┌──────┐
│ data │
├──────┤
│ 1 │
│ 2 │
│ 3 │
└──────┘
my_second_table
┌─────────────┐
│ column_name │
├─────────────┤
│ foo │
└─────────────┘
Code: Select all
SELECT "data" AS ( SELECT "column_name" FROM "my_second_table" ) FROM "my_table"
Code: Select all
╒═════╕
│ foo │
╞═════╡
│ 1 │
│ 2 │
│ 3 │
└─────┘
I'm using HSQLDB version 1.8.