If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Obtain only alphabets from table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-30-04, 01:55
yug229 yug229 is offline
Registered User
 
Join Date: Jun 2004
Posts: 1
Obtain only alphabets from table

There is a table name "testtable". This table has three columns col1(char), col2(int) and col3(char). The data in the table will be as mentioned below:

------------------------------------------
Col1 Col2 Col3
0 0 0
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
a 10 A
A 11 A
b 12 B
B 13 B
c 14 C
C 15 C
------------------------------------------

How can i get only the alphabets and not numerics from Col3 with the order by caluse on Col2?

The result should be as follows:
A
B
C

Please help me out to obtain the result as mentioned above.
Thanks in advance

Thanks,
Reddy
Reply With Quote
  #2 (permalink)  
Old 06-30-04, 03:26
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
SELECT * FROM testtable WHERE col3 IN ('A','B','C','D', ... ,'Z') ORDER BY col3

Replace "..." with character you would like to include in SQL.

Hope this helps,
Grofaty

Last edited by grofaty; 06-30-04 at 03:32.
Reply With Quote
  #3 (permalink)  
Old 06-30-04, 03:54
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
col3 between 'A' and 'Z' will also work, I guess
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #4 (permalink)  
Old 06-30-04, 04:21
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,

sathyaram_s this is good idea, but if you have non-english environment you will have to specify also non-english charachters!!! So yug229 if you are from english region then you shoud use sathyaram_s tip, else use my tip.

Hope this helps,
Grofaty

Last edited by grofaty; 06-30-04 at 04:24.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On