Aan de slagGa gratis aan de slag

Truncating strings

In the previous exercise, you calculated the length of the description column and noticed that the number of characters varied but most of the results were over 75 characters. There will be many times when you need to truncate a text column to a certain length to meet specific criteria for an application. In this exercise, we will practice getting the first 50 characters of the description column.

Deze oefening maakt deel uit van de cursus

Functions for Manipulating Data in PostgreSQL

Cursus bekijken

Oefeninstructies

  • Select the first 50 characters of the description column with the alias short_desc

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

SELECT 
  -- Select the first 50 characters of description
  ___(___, ___) AS ___
FROM 
  film AS f; 
Code bewerken en uitvoeren