Which function and value should you insert for <target1> and <target2> to display the previous year's sales in the given window function?

Prepare for the DP-600 Fabric Analytics Engineer Exam. Study with flashcards and multiple choice questions, each offering hints and detailed explanations. Enhance your chances of success on the exam!

Multiple Choice

Which function and value should you insert for <target1> and <target2> to display the previous year's sales in the given window function?

Explanation:
To display the previous year's sales, you access the value from the preceding row within the same partition as you order by year. The LAG function returns a value from an earlier row, and an offset of 1 moves to the immediate previous row. If there is one row per year in each partition, that previous row corresponds to last year. Therefore, the correct combination is LAG with an offset of 1. Using LEAD would fetch the next year, and an offset of 2 would skip an extra year, not give the previous year.

To display the previous year's sales, you access the value from the preceding row within the same partition as you order by year. The LAG function returns a value from an earlier row, and an offset of 1 moves to the immediate previous row. If there is one row per year in each partition, that previous row corresponds to last year. Therefore, the correct combination is LAG with an offset of 1. Using LEAD would fetch the next year, and an offset of 2 would skip an extra year, not give the previous year.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy