My schema looks like
select dob, name from student;
DOB NAME
--------- -------
01-APR-68 rylan
01-APR-70 joshua
01-APR-83 ava
01-APR-76 adalgisa
01-APR-83 zaida
01-APR-83 perry
01-APR-82 aiden
01-APR-75 madison
01-APR-62 zoe
01-APR-72 brendon
01-APR-75 cayden
01-APR-83 hannah
When I try to get age
from date of birth as
SELECT DISTINCT s.NAME,
s.ssn,
s.address.streetName AS street,
( Floor (Months_between(Trunc(sysdate), s.dob) / 12) ) AS age
FROM student s,
student s1
WHERE s.dob = (SELECT Max(DISTINCT dob)
FROM student);
NAME SSN STREET AGE
----- -------- ------------ ---
perry 111110003 union square -69
zaida 111110000 5th street -69
hannah 111111111 union square -69
ava 111118888 5th street -69
The age is coming as negative, I have no idea why this is happening, can someone please point out the issue with the query?
Thanks
I am using Oracle
Database