Type casting and trim() in DB2

inversojvo
inversojvo used Ask the Experts™
on
Hi,

siehe http://www.experts-exchange.com/Database/DB2/Q_26537565.html

-----------------------------

I looked at the table again. Indeed the column "scoringklasse" has the data type varchar(10).

The table is not sorted, if I use
select *
from table
order by scoringklasse

Do I have any possibility to use anything as a casting, e.g.
select *
from table
order by int(scoringklasse)?

Is there a trim-function to delete the leading spaces, e.g.
select *
from table
order by int(trim(scoringklasse))?

Unfortunetaly we may not change the data type of the column "scoringklasse". It has to stay varchar(10).

Many thanks in advance and have a nice evening!



Many thanks and have a nice day!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can use the CAST macro to change data types in your select. And you can use numbered fields in the 'order by', but you wouldn't want to use 'select *' if you did that.

i.e.

SELECT CAST (TRIM(scoringklasse) AS int)
FROM table
ORDER BY 1

Author

Commented:
Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial