Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 6968
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 Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Allianz Technology - Mainframe 3+ Yea... sooraj184 Mainframe Jobs 0 Mon Jul 31, 2017 2:17 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts CA-Endevor Admin - 3 years minimum vasanthz Mainframe Jobs 0 Tue Apr 04, 2017 5:36 am
No new posts Multi row fetch - "for read only... Nileshkul DB2 3 Sun Aug 14, 2016 12:52 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us