0
0
PostgreSQLquery~10 mins

CROSS JOIN behavior 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 columns from both tables using CROSS JOIN.

PostgreSQL
SELECT * FROM table1 [1] table2;
Drag options to blanks, or click blank then click option'
ACROSS JOIN
BINNER JOIN
CLEFT JOIN
DRIGHT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN instead of CROSS JOIN.
Forgetting that CROSS JOIN does not need an ON clause.
2fill in blank
medium

Complete the code to count the total number of rows after a CROSS JOIN between two tables.

PostgreSQL
SELECT COUNT(*) FROM tableA [1] tableB;
Drag options to blanks, or click blank then click option'
AFULL JOIN
BINNER JOIN
CLEFT JOIN
DCROSS JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN which filters rows.
Using FULL JOIN which includes NULLs.
3fill in blank
hard

Fix the error in the query to correctly perform a CROSS JOIN between employees and departments.

PostgreSQL
SELECT employees.name, departments.name FROM employees [1] departments;
Drag options to blanks, or click blank then click option'
AINNER JOIN
BCROSS JOIN
CLEFT JOIN
DRIGHT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using ON clause with CROSS JOIN.
Confusing CROSS JOIN with INNER JOIN.
4fill in blank
hard

Fill both blanks to create a query that selects all pairs of product and color using CROSS JOIN and orders by product name.

PostgreSQL
SELECT products.name, colors.name FROM products [1] colors ORDER BY products.[2];
Drag options to blanks, or click blank then click option'
ACROSS JOIN
BINNER JOIN
Cname
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN instead of CROSS JOIN.
Ordering by a wrong column.
5fill in blank
hard

Fill all three blanks to create a query that selects employee names, department names, and their combined count using CROSS JOIN and GROUP BY.

PostgreSQL
SELECT employees.[1], departments.[2], COUNT(*) FROM employees [3] departments GROUP BY employees.name, departments.name;
Drag options to blanks, or click blank then click option'
Aname
Bdepartment_name
CCROSS JOIN
DINNER JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN instead of CROSS JOIN.
Selecting wrong column names.