Subject ORDER BY not working on a View
Author ivanodm
Consider a database with the following structure:

CREATE TABLE TABLE1 ( ID1 INTEGER, DES1 VARCHAR(20) );
CREATE TABLE TABLE2 ( ID2 INTEGER, DES2 VARCHAR(20) );

INSERT INTO TABLE1 (ID1, DES1) VALUES (1, 'ONE');
INSERT INTO TABLE1 (ID1, DES1) VALUES (2, 'TWO');
INSERT INTO TABLE1 (ID1, DES1) VALUES (3, 'THREE');
INSERT INTO TABLE1 (ID1, DES1) VALUES (4, 'FOUR');
INSERT INTO TABLE1 (ID1, DES1) VALUES (5, 'FIVE');
INSERT INTO TABLE1 (ID1, DES1) VALUES (6, 'SIX');
INSERT INTO TABLE1 (ID1, DES1) VALUES (7, 'SEVEN');

INSERT INTO TABLE2 (ID2, DES2) VALUES (1, '1');
INSERT INTO TABLE2 (ID2, DES2) VALUES (2, '2');
INSERT INTO TABLE2 (ID2, DES2) VALUES (3, '3');
INSERT INTO TABLE2 (ID2, DES2) VALUES (4, '4');
INSERT INTO TABLE2 (ID2, DES2) VALUES (5, '5');
INSERT INTO TABLE2 (ID2, DES2) VALUES (6, '6');
INSERT INTO TABLE2 (ID2, DES2) VALUES (7, '7');

RECREATE VIEW VIEW_TABLE ( ID1, DES1, DES2 )
AS
SELECT DISTINCT(TABLE1.ID1), TABLE1.DES1, TABLE2.DES2
FROM TABLE1
LEFT JOIN TABLE2 ON ( TABLE1.ID1 = TABLE2.ID2 );


Then run this query under Firebird 2.0.3:

SELECT ID1, DES1 FROM VIEW_TABLE ORDER BY DES1;

The results come out unsorted. The same query issued against the same
database with Firebird 1.5 give the results correctly sorted.

The get the ORDER BY work with Firebird 2 we have to eliminate the
DISTINCT on TABLE1.ID1.

Is it a feature? I couldn't find anything helpful in the release
notes of Firebird 2.

Thank you for your help.