0
0
PostgreSQLquery~10 mins

Type casting with :: operator 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 cast the string '123' to an integer using the :: operator.

PostgreSQL
SELECT '123'[1]integer;
Drag options to blanks, or click blank then click option'
A->
B=>
C::
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using -> or => instead of :: for casting.
Trying to use == which is a comparison operator.
2fill in blank
medium

Complete the code to cast the integer 45 to text using the :: operator.

PostgreSQL
SELECT 45[1]text;
Drag options to blanks, or click blank then click option'
A->
B::
C=>
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using -> or => which are not casting operators.
Using == which is for comparison, not casting.
3fill in blank
hard

Fix the error in the code to correctly cast the string '3.14' to a numeric type.

PostgreSQL
SELECT '3.14'[1]numeric;
Drag options to blanks, or click blank then click option'
A->
B=>
C==
D::
Attempts:
3 left
💡 Hint
Common Mistakes
Using -> or => which cause syntax errors.
Using == which is a comparison operator.
4fill in blank
hard

Fill both blanks to cast the string '2024-06-01' to a date and then to text.

PostgreSQL
SELECT ('2024-06-01'[1]date)[2]text;
Drag options to blanks, or click blank then click option'
A::
B->
D=>
Attempts:
3 left
💡 Hint
Common Mistakes
Using -> or => instead of :: for casting.
Forgetting parentheses around the first cast.
5fill in blank
hard

Fill all three blanks to cast the string '100' to integer, multiply by 2, and cast the result to text.

PostgreSQL
SELECT (( '100'[1]integer ) * [2] )[3]text;
Drag options to blanks, or click blank then click option'
A::
B2
D->
Attempts:
3 left
💡 Hint
Common Mistakes
Using -> instead of :: for casting.
Forgetting to multiply by 2.
Not casting the final result to text.