0
0
PostgreSQLquery~10 mins

String collation and sort order in PostgreSQL - Interactive Code Practice

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

Complete the code to select all names sorted alphabetically using the default collation.

PostgreSQL
SELECT name FROM users ORDER BY name [1];
Drag options to blanks, or click blank then click option'
AASC
BDESC
CCOLLATE
DGROUP
Attempts:
3 left
💡 Hint
Common Mistakes
Using DESC sorts in reverse order.
Using COLLATE here without specifying collation causes error.
2fill in blank
medium

Complete the code to sort names using the French collation.

PostgreSQL
SELECT name FROM users ORDER BY name COLLATE [1];
Drag options to blanks, or click blank then click option'
A'es_ES.UTF-8'
B'de_DE.UTF-8'
C'en_US.UTF-8'
D'fr_FR.UTF-8'
Attempts:
3 left
💡 Hint
Common Mistakes
Using English or other locale codes instead of French.
Forgetting to put quotes around the collation name.
3fill in blank
hard

Fix the error in the code to sort names case-sensitively using the C collation.

PostgreSQL
SELECT name FROM users ORDER BY name COLLATE [1];
Drag options to blanks, or click blank then click option'
A'POSIX'
B'C'
C'utf8_general_ci'
D'en_US.UTF-8'
Attempts:
3 left
💡 Hint
Common Mistakes
Using MySQL collation names like 'utf8_general_ci' which are invalid in PostgreSQL.
Using locale names like 'en_US.UTF-8' without quotes.
4fill in blank
hard

Fill both blanks to select names sorted ascending with German collation and case-sensitive.

PostgreSQL
SELECT name FROM users ORDER BY name COLLATE [1] [2];
Drag options to blanks, or click blank then click option'
A'de_DE.UTF-8'
BASC
CDESC
D'fr_FR.UTF-8'
Attempts:
3 left
💡 Hint
Common Mistakes
Using French collation instead of German.
Using DESC instead of ASC for ascending order.
5fill in blank
hard

Fill both blanks to select names sorted descending with Spanish collation and case-sensitive.

PostgreSQL
SELECT name FROM users ORDER BY name COLLATE [1] [2];
Drag options to blanks, or click blank then click option'
A'es_ES.UTF-8'
BDESC
CASC
D'C'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ascending order when descending is asked.
Using wrong locale codes.