0
0
PostgreSQLquery~10 mins

VALUES clause for inline data 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 create a table with inline data using VALUES.

PostgreSQL
SELECT * FROM ([1] (1, 'Apple'), (2, 'Banana'));
Drag options to blanks, or click blank then click option'
AFROM
BVALUES
CTABLE
DINSERT
Attempts:
3 left
💡 Hint
Common Mistakes
Using TABLE instead of VALUES
Using INSERT in a SELECT statement
Omitting the VALUES keyword
2fill in blank
medium

Complete the code to assign column names to the inline data using VALUES.

PostgreSQL
SELECT id, name FROM (VALUES (1, 'Orange'), (2, 'Grape')) AS [1](id, name);
Drag options to blanks, or click blank then click option'
Afruits
Bdata
Ctable
Ditems
Attempts:
3 left
💡 Hint
Common Mistakes
Not providing an alias after VALUES
Using reserved words as alias
Omitting column names after alias
3fill in blank
hard

Fix the error in the code to correctly use VALUES with column names.

PostgreSQL
SELECT * FROM (VALUES (1, 'Pear'), (2, 'Peach')) [1] fruits(id, name);
Drag options to blanks, or click blank then click option'
AIS
BINTO
CAS
DON
Attempts:
3 left
💡 Hint
Common Mistakes
Using INTO instead of AS
Omitting the alias keyword
Using ON or IS which are incorrect here
4fill in blank
hard

Fill both blanks to select only rows where id is greater than 1 from inline data.

PostgreSQL
SELECT * FROM (VALUES (1, 'Mango'), (2, 'Kiwi'), (3, 'Lime')) AS [1](id, name) WHERE id [2] 1;
Drag options to blanks, or click blank then click option'
Afruits
B>
C<
Ditems
Attempts:
3 left
💡 Hint
Common Mistakes
Using alias names that are not assigned
Using wrong comparison operators like < instead of >
Omitting the WHERE clause
5fill in blank
hard

Fill all three blanks to create inline data with alias and select names starting with 'B'.

PostgreSQL
SELECT name FROM (VALUES (1, 'Blueberry'), (2, 'Blackberry'), (3, 'Strawberry')) AS [1]([2], [3]) WHERE name LIKE 'B%';
Drag options to blanks, or click blank then click option'
Aberries
Bid
Cname
Dfruit
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect alias or column names
Omitting the alias or column list
Using wrong LIKE pattern