Sybase IQ does not return the rows in a result set in any particular order. Adding an ORDER BY clause to a SELECT statement returns the results in alphabetical or numerical order.
Adding an ORDER BY clause to a SELECT statement returns the result set in alphabetical or numeric order. The order of the clauses is important. The ORDER BY clause must follow the FROM clause and the SELECT clause. For example:
SELECT * FROM Employees ORDER BY Surname
EmployeeID |
ManagerID |
Surname |
GivenName |
DepartmentID |
... |
---|---|---|---|---|---|
1,751 |
1,576 |
Ahmed |
Alex |
400 |
... |
1,013 |
703 |
Barker |
Joseph |
500 |
... |
591 |
1,576 |
Barletta |
Irene |
400 |
... |
191 |
703 |
Bertrand |
Jeannette |
500 |
... |
1,336 |
1,293 |
Bigelow |
Janet |
300 |
... |
1,062 |
1,576 |
Blaikie |
Barbara |
400 |
... |
750 |
703 |
Braun |
Jane |
500 |
... |
160 |
501 |
Breault |
Robert |
100 |
... |
1,191 |
1,576 |
Bucceri |
Matthew |
400 |
... |
If you have a query that does not require a FROM clause, you can force the query to be processed by Sybase IQ by adding the clause FROM iq_dummy, where iq_dummy is a one-row, one-column table that you create in your database.