DECFLOAT_SORTKEY

The DECFLOAT_SORTKEY function returns a binary value that may be used to sort DECFLOAT values.

Example:

CREATE TABLE T1 (D1 DECFLOAT(16)); 
INSERT INTO T1 VALUES(2.100); 
INSERT INTO T1 VALUES(2.10); 
INSERT INTO T1 VALUES(2.1000); 
INSERT INTO T1 VALUES(2.1);
SELECT D1 FROM T1 ORDER BY D1; 
2.100 
2.10 
2.1000 
2.1

Note that this result set is arbitrary. The ORDER BY has no effect on ordering these values.

SELECT D1 FROM T1 ORDER BY DECFLOAT_SORTKEY(D1); 
2.1000 
2.100 
2.10 
2.1

Note that this result set is ordered according to the IEEE 745R ordering specification.