7. SELECT: ORDER BY

ORDER BY takes columns: a list of column names (or expressions), and you can add ASC (the default) or DESC (descending order):

SELECT TOP 5 *
FROM rave.dr2
ORDER BY rv
SELECT TOP 5 *
FROM rave.dr2
ORDER BY rv DESC
SELECT TOP 5 *
FROM rave.dr2
ORDER BY fiber_number, rv

Note that ordering is outside of the relational model. That sometimes matters because it may mess up query planning (a rearrangement of relational expressions done by the database engine to make them run faster)

Problems

(1)

Select the (rows of) the 20 brightest stars in the table fk6.part1.


Markus Demleitner, Hendrik Heinl

Copyright Notice