This might be a stupid question. Imaging following table in Postgres:
create table scientist (id integer, firstname varchar(100), lastname varchar(100));
insert into scientist (id, firstname, lastname) values (1, 'albert', 'einstein');
A simple select of all fields:
select id, firstname, lastname scientist;
results in:
| is | firstname | lastname |
|---|---|---|
| 1 | albert | einstein |
Is there some way to add a kind of non-existing empty virtual field f.e. age?
Pseudo Code:
select
id,
firstname,
lastname,
age as '' -- my non existing field that should show up in the results
from
scientist;
that the result looks like?
| is | firstname | lastname | age |
|---|---|---|---|
| 1 | albert | einstein |
>Solution :
It’s the other way round: as defines a column alias, so
'' as age
will work.
However, I’d be quite surprised about a column named age in a result that is a character value, not an integer. If you want a typed value, you can also use null::int as age