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
 
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 A couple of Interview Questions on Co... viplavmodi36 Mainframe Interview Questions 5 Fri Feb 23, 2018 6:21 pm
No new posts JES2 EXIT 6 QUESTION Randy Horowitz All Other Mainframe Topics 30 Tue Feb 06, 2018 5:47 pm
No new posts question about dfsms management clas... Hervey Martinez IBM Tools 0 Tue Oct 10, 2017 6:19 pm
No new posts Question related to Data dictionary f... rexx77 SYNCSORT 3 Thu Aug 31, 2017 7:23 am
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am

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