Ga naar inhoud

Header

Sorting with ORDER BY - Assignments

1. Default sorting by first names of actors

Complete the following query to obtain all data from the actors table. Sort by default (ascending) on the first name of actors (column first_name).

  • Use SELECT and FROM to make the selection.
  • Use ORDER BY to sort by column first_name.
...
  *
...
  actors
...
  ...;




2. Default sorting by number of films of actors

Complete the following query to obtain all data from the actors table. Sort by default (ascending) on the number of films of actors (column film_count).

  • Use ORDER BY to sort by column film_count.
...
  ...
...
  ...
...
  ...;




3. Descending sorting by number of films of actors

Complete the following query to obtain all data from the actors table. Sort descending by the number of films of actors (column film_count).

  • Use ORDER BY and keyword DESC to sort descending by column film_count.
...
  ...
...
  ...
...
  ... ...;




4. Descending and ascending sorting by number of films and first names of actors

Complete the following query to obtain all data from the actors table.

  • Sort descending by the number of films of actors (column film_count).
  • And ascending by the first name of actors (column first_name).
  • Use ORDER BY and keywords ASC and DESC.
...
  ...
...
  ...
...
  ... ...,
  ... ...;




5. (Extra) Sorting by the number of characters in the last name

Complete the following query to obtain all data from the actors table.

  • Sort ascending by the number of characters in the last name of actors.
  • Use the function LENGTH().
...




6. (Extra) Sorting by the number of characters in the last name

Complete the following query to obtain a selection of data from the actors table.

  • Select (filter) where the second letter in the first name is equal to o, regardless of whether it is lowercase or uppercase.
  • Also select where the number of films is greater than 1.
  • Sort descending the first name of actors.
...