View previous topic :: View next topic
|
Author |
Message |
santhosh_kumar
New User
Joined: 31 May 2007 Posts: 4 Location: Chennai
|
|
|
|
1. I want to select 5 fields from a db2 table of which 2 are varchar field of length 50 bytes.
2. Requirement is to view only the first 15 char of the 2 varchar field and also to sort those 2 varchar fields in ascending order.
3. I cannot use SUBSTR(Column_Name,1,15) in SELECT stament because ORDER BY clause is having the Column_Name.
I am looking for some guidance...
Thanks,
Santhosh |
|
Back to top |
|
|
saiprasadh
Active User
Joined: 20 Sep 2006 Posts: 154 Location: US
|
|
|
|
Hi Santosh,
Please find the query.
Code: |
select field1,substr(field2,1,15),substr(field3,1,15) from table1
order by 1 asc, 2 asc, 3 asc with ur; |
Regards
Sai |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
should only be used when design permits.
otherwise, you can have incorrect results if a rollback occurs after your select. |
|
Back to top |
|
|
|