A raw shelf returns scrolls in no particular order. ORDER BY lets you arrange them - from oldest, from cheapest, alphabetically - however your heart desires.
By default the sorting is ascending (
ASC). If you give no direction, the Library will still arrange the scrolls ascending:1SELECT tytul, rok_wydania
2FROM ksiazki
3ORDER BY rok_wydania ASC;To reverse the order - from largest to smallest - use
DESC:1SELECT tytul, rok_wydania
2FROM ksiazki
3ORDER BY rok_wydania DESC;This query shows the books newest first. And this is how you arrange books cheapest first:
1SELECT tytul, cena
2FROM ksiazki
3ORDER BY cena ASC;Always after FROM, near the end of the query:
1SELECT imie, nazwisko FROM autorzy ORDER BY nazwisko ASC;ORDER BY is the scribe's hand that tidies scattered scrolls upon the shelf. In the next lesson you will learn to sort by several fields at once.