Databricks Certified Data Engineer Associate · Free Practice Question Medium
Question 25
The data engineering team has a Delta table called products that contains products’ details including the net price.
Which of the following code blocks will apply a 50% discount on all the products where the price is greater than 1000 and save the new price to the table?
-
A
UPDATE products SET price = price * 0.5 WHERE price >= 1000;
-
B
MERGE INTO products WHERE price > 1000 WHEN MATCHED UPDATE price = price * 0.5;
-
C
SELECT price * 0.5 AS new_price FROM products WHERE price > 1000;
Reveal correct answer
Correct answer:
Explanation
The UPDATE statement is used to modify the existing records in a table that match the WHERE condition. In this case, we are updating the products where the price is strictly greater than 1000.
Syntax:
- UPDATE table_name
- SET column_name = expr
- WHERE condition
Study materials from our exam preparation course on Udemy:
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
