- Get the first 50 characters of the
description
column - Determine the position of the last whitespace character of the truncated
description
column and subtract it from the number 50 as the second parameter in the first function above.
SELECT
UPPER(c.name) || ': ' || f.title AS film_category,
-- Truncate the description without cutting off a word
LEFT(description, 50 -
-- Subtract the position of the first whitespace character
POSITION(
' ' IN REVERSE(LEFT(description, 50))
)
)
FROM
film AS f
INNER JOIN film_category AS fc
ON f.film_id = fc.film_id
INNER JOIN category AS c
ON fc.category_id = c.category_id;
film_category | left |
---|---|
ACTION: WEREWOLF LOLA | A Fanciful Story of a Man And a Sumo Wrestler who |
ACTION: WATERFRONT DELIVERANCE | A Unbelieveable Documentary of a Dentist And a |
ACTION: UPRISING UPTOWN | A Fanciful Reflection of a Boy And a Butler who |
ACTION: TRUMAN CRAZY | A Thrilling Epistle of a Moose And a Boy who must |
ACTION: TRIP NEWTON | A Fanciful Character Study of a Lumberjack And a |
Komentar
Posting Komentar