Reputation: 21
I am trying to write a query in order to pull up the age difference between the oldest and youngest pilots in my pilots table - so far I've tried this which returns days when I need years:
SELECT ROUND(MAX(PIL_BRTHDATE)-(MIN(PIL_BRTHDATE),2) AS "AGE DIFFERENCE" FROM PILOTS;
The ROUND
is there because my professor wants it rounded to the 2nd decimal.
I tried the DATEDIFF
function but since I can't just input the start and end dates manually it's not working (YY,"STARTDATE","ENDDATE"
).
For example I tried:
DATEDIFF(YY,MAX(PIL_BRTHDATE),MIN(PIL_BRTHDATE))...IT KEEPS SAYING INVALID IDENTIFIER
Upvotes: 2
Views: 532