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

db2 interview question


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
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
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
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: 1448
Location: Chicago, IL

PostPosted: Mon Apr 10, 2006 1:28 pm
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: 1448
Location: Chicago, IL

PostPosted: Mon Apr 10, 2006 1:37 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Question for file manager IBM Tools 7
No new posts question for Pedro TSO/ISPF 2
No new posts question on Outrec and sort #Digvijay DFSORT/ICETOOL 20
No new posts panel creation question TSO/ISPF 12
No new posts Sort w/OUTREC Question DFSORT/ICETOOL 2
Search our Forums:

Back to Top