Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Fetch employee name whose age is less than 70 years

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Fetch employee name whose age is less than 70 years
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Multi row fetch - "for read only... Nileshkul DB2 3 Sun Aug 14, 2016 12:52 am
No new posts Mainframe Openings for 3 to 5 years i... muralikrishnan_new Mainframe Jobs 0 Fri Jun 17, 2016 4:48 pm
No new posts JCL to fetch schedule status from act... parasmalik20 CA Products 1 Thu Jun 02, 2016 7:11 pm
No new posts ABEND due to FETCH FAILED jackzhang75 ABENDS & Debugging 17 Thu Mar 10, 2016 3:08 am
No new posts Sort Query to fetch particular records RahulG31 DFSORT/ICETOOL 13 Fri Mar 04, 2016 8:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us