Correct Answer: B
LAG is basically an analytic operator that allows us to look up a previous event part of an event stream. It is majorly used in finding the growth or change or a particular variable, which is the temperature of the Panel.
As the name suggests, LIMIT DURATION will be used to restrict the interval or time considered while computing this query.
In total, LAG and LIMIT DURATION determine how far we have to do the lookup of history.
Option A is incorrect: Using LAG is correct here. But when the use of WHEN is like adding a condition and not for a timeframe /interval, that makes the option a wrong choice.
Option B is correct: The use of LAG and LIMIT DURATION works perfectly in this case.
Option C is incorrect: LAST is used for the lookup of the most recent event. But using LIMIT DURATION is correct. Since the first condition is wrong, this option will not be the best choice.
Option D is incorrect: LAST and WHEN cannot be used here.
Reference:
To know more, please refer to the docs below:
https://docs.microsoft.com/en-us/stream-analytics-query/lag-azure-stream-analytics#general-remarks