Hi all,
There is an employee table in which employee name(emp_name) and employee date of birth (emp_dob) are the two fields.I want to fetch employee name whose age is less than 70 years.
Can any one suggest me a efficient query?
Joined: 20 Oct 2006 Posts: 6970 Location: porcelain throne
Code:
Select emp_name
from your.table
where emp_dob > current_date - 70 years
what data type is emp_dob? if it is a date field, then a variation on my suggestion will work.
but, if you have dates in columns which are not defined as date, then you are on your own.
this query is designed for Spufi or QMF.
If it will be embedded in a program,
you will have to DECLARE a cursor with the approriate WHERE clause,
and FETCH rows until SLQ-CODE <> 0.