0
0
PostgreSQLquery~10 mins

Why PostgreSQL string functions are powerful - Test Your Understanding

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

Complete the code to convert the string 'hello' to uppercase using a PostgreSQL function.

PostgreSQL
SELECT [1]('hello');
Drag options to blanks, or click blank then click option'
ATRIM
BLOWER
CINITCAP
DUPPER
Attempts:
3 left
💡 Hint
Common Mistakes
Using LOWER instead of UPPER.
Using TRIM which removes spaces, not changes case.
2fill in blank
medium

Complete the code to find the position of the substring 'cat' in the string 'concatenate'.

PostgreSQL
SELECT POSITION([1] IN 'concatenate');
Drag options to blanks, or click blank then click option'
A'cat'
B'rat'
C'bat'
D'dog'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a substring that does not exist in the string.
Forgetting to put the substring in quotes.
3fill in blank
hard

Fix the error in the code to extract the first 4 characters from the string 'PostgreSQL'.

PostgreSQL
SELECT SUBSTRING('PostgreSQL' [1] 4);
Drag options to blanks, or click blank then click option'
ASTART 1 LENGTH
BFOR 4 FROM 1
CFROM 1 FOR
DFROM 4 FOR
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of FOR and FROM.
Using incorrect keywords like START or LENGTH.
4fill in blank
hard

Fill both blanks to trim spaces from both ends of the string and convert it to lowercase.

PostgreSQL
SELECT [1]([2]('  Hello World  '));
Drag options to blanks, or click blank then click option'
ALOWER
BUPPER
CTRIM
DINITCAP
Attempts:
3 left
💡 Hint
Common Mistakes
Using UPPER instead of LOWER for case conversion.
Not trimming spaces before changing case.
5fill in blank
hard

Fill all three blanks to create a query that replaces 'day' with 'night' in the string, converts it to uppercase, and trims spaces.

PostgreSQL
SELECT [1]([2](REPLACE('Good day  ', [3], 'night')));
Drag options to blanks, or click blank then click option'
ATRIM
BUPPER
C'day'
DREPLACE
Attempts:
3 left
💡 Hint
Common Mistakes
Putting TRIM inside REPLACE incorrectly.
Not quoting the substring 'day'.
Changing case before replacing.