0

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

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.