0
0
SQLquery~10 mins

Why string functions matter in queries in SQL - Test Your Understanding

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

Complete the code to select the first 3 characters of the name column.

SQL
SELECT SUBSTR(name, 1, [1]) FROM employees;
Drag options to blanks, or click blank then click option'
A3
B5
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as length returns empty string.
Using 1 returns only the first character.
2fill in blank
medium

Complete the code to convert the email column to lowercase.

SQL
SELECT [1](email) FROM users;
Drag options to blanks, or click blank then click option'
ALOWER
BLENGTH
CTRIM
DUPPER
Attempts:
3 left
💡 Hint
Common Mistakes
Using UPPER instead of LOWER.
Using LENGTH which returns number, not string.
3fill in blank
hard

Fix the error in the code to find the position of '@' in the email column.

SQL
SELECT INSTR(email, [1]) FROM contacts;
Drag options to blanks, or click blank then click option'
A'at'
B@
C'@'
Dat
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around '@'.
Using the word 'at' instead of '@'.
4fill in blank
hard

Fill both blanks to trim spaces and convert the username column to uppercase.

SQL
SELECT [1]([2](username)) FROM users;
Drag options to blanks, or click blank then click option'
AUPPER
BLOWER
CTRIM
DSUBSTR
Attempts:
3 left
💡 Hint
Common Mistakes
Reversing the order of functions.
Using LOWER instead of UPPER.
5fill in blank
hard

Fill all three blanks to create a dictionary of usernames and their email domains (part after '@').

SQL
SELECT [1], SUBSTR(email, INSTR(email, [2]) + 1) AS domain FROM users WHERE email [3] '%@%';
Drag options to blanks, or click blank then click option'
Ausername
B'@'
CLIKE
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using email instead of username.
Not quoting '@' in INSTR.
Using = instead of LIKE.