IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Fetch employee name whose age is less than 70 years


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sant532

New User


Joined: 02 Jun 2008
Posts: 48
Location: India

PostPosted: Wed Nov 19, 2008 9:00 pm
Reply with quote

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?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Nov 19, 2008 9:11 pm
Reply with quote

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.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Code Multi Row fetch in PL1 program PL/I & Assembler 1
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts Mainframe developers 3 - 6 years exp Mainframe Jobs 0
No new posts fetch the record number from FMNMAIN ... CLIST & REXX 10
Search our Forums:

Back to Top