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
 

 

db2 interview question

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
vadivelumohan

New User


Joined: 29 Mar 2006
Posts: 3
Location: chennai

PostPosted: Sun Apr 09, 2006 1:29 pm    Post subject: db2 interview question
Reply with quote

hi
if the table contains four column like name ,salary, date,date of join and phone number.whats query to retrieve phone number which contains last four digits is between 4000 to 5000
Back to top
View user's profile Send private message

sri.mainframes

New User


Joined: 16 Feb 2006
Posts: 29
Location: MUMBAI

PostPosted: Mon Apr 10, 2006 1:12 pm    Post subject:
Reply with quote

hi mohan,

This might help you

select RIGHT(phonenumber, 4) as phoneno
from tablename
where phoneno between 4000 and 5000;

correct me if i am wrong

regards
sri.prince
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Apr 10, 2006 1:28 pm    Post subject: Re: db2 interview question
Reply with quote

What is the length of Phone Number field ?

Quote:
how to Bringing Up/Down of Database in mainframes

Is that your signature line ?

Regards,
Priyesh.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Apr 10, 2006 1:37 pm    Post subject: Re: db2 interview question
Reply with quote

sri.prince,

Try your query incase PHONENUMBER is a field greater than length of 4. It'll not give desired result.

vadivelumohan,

Try this...
Code:
SELECT PHONENUMBER FROM CREATOR.TABLENAME
WHERE
SUBSTR(PHONENUMBER,L-3,4) >= 4000
AND
SUBSTR(PHONENUMBER,L-3,4) < 5001;

*L- Length of the field of PHONENUMBER in TABEL.

Regards,
Priyesh.
Back to top
View user's profile Send private message
madhu_910

New User


Joined: 21 Feb 2005
Posts: 10

PostPosted: Mon Apr 10, 2006 3:57 pm    Post subject: Re: db2 interview question
Reply with quote

to simplify this you can also give
Code:
select  phonenumber from tablename where right(phonenumber,4)between  '4000' and '5000'

I think this should help you.

rgds,
Madhu
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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am
No new posts Asynchronous CICS Processing Question moezbud CICS 1 Mon Mar 06, 2017 6:13 pm
No new posts CICS Question RE: Browse, Readnext an... moezbud CICS 7 Sun Mar 05, 2017 5:45 am
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm


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