View previous topic :: View next topic
|
Author |
Message |
vadivelumohan
New User
Joined: 29 Mar 2006 Posts: 3 Location: chennai
|
|
|
|
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 |
|
|
sri.mainframes
New User
Joined: 16 Feb 2006 Posts: 29 Location: MUMBAI
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
madhu_910
New User
Joined: 21 Feb 2005 Posts: 10
|
|
|
|
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 |
|
|
|