1. Belajar
  2. /
  3. Kursus
  4. /
  5. Intermediate SQL

Connected

Latihan

Aliasing with functions

Aliasing can be a lifesaver, especially as we start to do more complex SQL queries with multiple criteria. Aliases help you keep your code clean and readable. For example, if you want to find the MAX() value of several fields without aliasing, you'll end up with the result with several columns called max and no idea which is which. You can fix this with aliasing.

Now, it's over to you to clean up the following queries.

Instruksi 1/3

undefined XP
  • 1
    • Select the title and duration in hours for all films and alias as duration_hours; since the current durations are in minutes, you'll need to divide duration by 60.0.
  • 2
    • Calculate the percentage of people who are no longer alive and alias the result as percentage_dead.
  • 3
    • Find how many decades (period of ten years) the films table covers by using MIN() and MAX(); alias as number_of_decades.