sql - how to create a new field to show, together with the SELECT'ed fields? -


these code lines filter of people on 50.

select birthday table_name birthday < now() - '50 years'::interval 

together this, need create additional column, shows actual age.

es.

  birthday     age  2000-06-28    16 

the column "age" shall created select. not present in table.

you can use specific function called age()

select extract(year age(birth_date)) age ... 

https://www.postgresql.org/docs/9.5/static/functions-datetime.html

enter image description here

enter image description here

keep in mind: age subtracts current_date (at midnight)


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -