views:

30

answers:

1

When I execute a query from my application (Java JDBC), it is returning the row with seq 83 first. But I want the row with seq 84.

seq   |   dtCreated         |
84    | 2009-09-14 16:16:23 |
83    | 2009-09-14 16:16:23 |
82    | 2009-09-14 16:15:01 |

Is this query correct ? I'm interpreting this to mean that if there are ties in dtCreated, sort using seq.

select * from mim order by dtCreated DESC, seq DESC;

Thanks

+1  A: 

Yes, you are inerpreting correct.

An Example

You can sort on multiple columns, and you can sort different columns in different directions. For example, to sort by type of animal in ascending order, then by birth date within animal type in descending order (youngest animals first), use the following query:

See the result from

SELECT name, species, birth FROM pet
ORDER BY species, birth DESC

provided in the example.

Svetlozar Angelov
Do you have a citation that backs this up ?
Jacques René Mesrine