0
0
SQLquery~10 mins

Non-equi joins in SQL - Interactive Code Practice

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

Complete the code to join two tables where the employee's salary is greater than the department's budget.

SQL
SELECT e.name, d.department_name FROM employees e JOIN departments d ON e.salary [1] d.budget;
Drag options to blanks, or click blank then click option'
A=
B<
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '>' causes the join to only match equal salaries and budgets.
Using '<' or '<=' will join rows where salary is less than or equal to budget, which is not what we want.
2fill in blank
medium

Complete the code to join orders and shipments where the shipment date is on or after the order date.

SQL
SELECT o.order_id, s.shipment_date FROM orders o JOIN shipments s ON s.shipment_date [1] o.order_date;
Drag options to blanks, or click blank then click option'
A>=
B<
C=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' only matches shipment dates exactly equal to order dates.
Using '<' or '<=' would match shipment dates before order dates, which is incorrect.
3fill in blank
hard

Fix the error in the join condition to correctly join products and discounts where the discount start date is before the product release date.

SQL
SELECT p.product_name, d.discount_rate FROM products p JOIN discounts d ON d.start_date [1] p.release_date;
Drag options to blanks, or click blank then click option'
A<
B>
C>=
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' or '>=' would mean the discount starts after or on the release date, which is wrong.
Using '=' only matches exact dates, missing other valid rows.
4fill in blank
hard

Fill both blanks to join employees and projects where the employee's experience is between the project's minimum and maximum experience requirements.

SQL
SELECT e.name, p.project_name FROM employees e JOIN projects p ON e.experience [1] p.min_experience AND e.experience [2] p.max_experience;
Drag options to blanks, or click blank then click option'
A>=
B<
C<=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using < or > incorrectly reverses the range logic.
Using '=' only matches exact experience values, missing others.
5fill in blank
hard

Fill all three blanks to join sales and targets where the sale amount is greater than the target minimum, less than the target maximum, and the sale date is on or after the target start date.

SQL
SELECT s.sale_id, t.target_name FROM sales s JOIN targets t ON s.amount [1] t.min_amount AND s.amount [2] t.max_amount AND s.sale_date [3] t.start_date;
Drag options to blanks, or click blank then click option'
A>
B<
C>=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= or >= incorrectly for amount comparisons.
Using < or > for date comparison misses the 'on or after' condition.