Complete the code to cast the string '123' to an integer using the :: operator.
SELECT '123'[1]integer;
The :: operator in PostgreSQL is used to cast a value to a specific type. Here, '123'::integer converts the string to an integer.
Complete the code to cast the integer 45 to text using the :: operator.
SELECT 45[1]text;
Using 45::text converts the integer 45 to a text string in PostgreSQL.
Fix the error in the code to correctly cast the string '3.14' to a numeric type.
SELECT '3.14'[1]numeric;
The correct way to cast a string to numeric in PostgreSQL is using the :: operator: '3.14'::numeric.
Fill both blanks to cast the string '2024-06-01' to a date and then to text.
SELECT ('2024-06-01'[1]date)[2]text;
First, cast the string to date using ::date, then cast the date to text using ::text.
Fill all three blanks to cast the string '100' to integer, multiply by 2, and cast the result to text.
SELECT (( '100'[1]integer ) * [2] )[3]text;
First cast '100' to integer with ::integer, multiply by 2, then cast the result to text with ::text.