0
0
SQLquery~10 mins

LENGTH and CHAR_LENGTH in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to find the length of the string 'Hello'.

SQL
SELECT [1]('Hello') AS length_value;
Drag options to blanks, or click blank then click option'
ALENGTH
BCOUNT
CSIZE
DLEN
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT which counts rows, not string length.
Using LEN which is not standard SQL.
Using SIZE which is not a string function.
2fill in blank
medium

Complete the code to find the number of characters in the string 'café'.

SQL
SELECT [1]('café') AS char_count;
Drag options to blanks, or click blank then click option'
ACHAR_LENGTH
BSIZE
CCOUNT
DLENGTH
Attempts:
3 left
💡 Hint
Common Mistakes
Using LENGTH which counts bytes, not characters.
Using COUNT which is for rows.
Using SIZE which is not a string function.
3fill in blank
hard

Fix the error in the code to correctly get the character length of the string 'naïve'.

SQL
SELECT [1]('naïve') AS length;
Drag options to blanks, or click blank then click option'
ALEN
BCHAR_LENGTH
CLENGTH
DCOUNT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LENGTH which counts bytes, not characters.
Using LEN which is not standard SQL.
Using COUNT which counts rows.
4fill in blank
hard

Fill both blanks to create a query that shows both byte length and character length of 'résumé'.

SQL
SELECT [1]('résumé') AS byte_length, [2]('résumé') AS char_length;
Drag options to blanks, or click blank then click option'
ALENGTH
BCHAR_LENGTH
CLEN
DCOUNT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEN which is not standard SQL.
Using COUNT which counts rows.
Mixing up LENGTH and CHAR_LENGTH.
5fill in blank
hard

Fill all three blanks to create a query that selects the string, its byte length, and its character length from a table named words.

SQL
SELECT word, [1](word) AS byte_len, [2](word) AS char_len FROM words WHERE [3](word) > 5;
Drag options to blanks, or click blank then click option'
ALENGTH
BCHAR_LENGTH
DCOUNT
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT in WHERE clause which counts rows, not string length.
Using LEN which is not standard SQL.
Mixing up LENGTH and CHAR_LENGTH in the wrong places.