I have the following table:
CREATE TABLE public.employees
(
employee_id integer NOT NULL,
name text NOT NULL,
date_of_birth date,
address text,
email text,
CONSTRAINT employees_pkey PRIMARY KEY (employees_id),
CONSTRAINT employees_email_key UNIQUE (email)
)
How would I be able to list each employee's name with their age in the output?
Thanks.
you can use age()
function like this :
SELECT name, EXTRACT(year FROM age(current_date,date_of_birth)) :: int as age FROM public.employees
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With