A table named Profits stores the total profit made each year within a territory. The Profits table has
columns named Territory, Year, and Profit.
You need to create a report that displays the profits made by each territory for each year and its
previous year.
Which Transact-SQL query should you use?

A.
SELECT Territory, Year, Profit,
LEAD(Profit, 1, 0) OVER (PARTITION BY Territory ORDER BY Year) AS PrevProfit
FROM Profits
B.
SELECT Territory, Year, Profit,
LAG(Profit, 1, 0) OVER (PARTITION BY Year ORDER BY Territory) AS PrevProfit
FROM Profits
C.
SELECT Territory, Year, Profit,
LAG(Profit, 1, 0) OVER (PARTITION BY Territory ORDER BY Year) AS PrevProfit
FROM Profits
D.
SELECT Territory, Year, Profit,
LEAD(Profit, 1, 0) OVER (PARTITION BY Year ORDER BY Territory) AS PrevProfit
FROM Profits
Explanation:
http://msdn.microsoft.com/en-us/library/hh231256.aspx http://msdn.microsoft.com/en-us/library/hh213125.aspx
C
0
0
pls explain
0
0
The LAG function returns an element from the row in the
current partition that is a requested number of rows before the current row (based on the
window ordering), with 1 assumed as the default offset.
here we need to partition by Territory and order by year ASC
0
0
c
0
0
By the way, part of that new 200Q 70-461 dumps are available here:
https://drive.google.com/open?id=0B-ob6L_QjGLpfnJldlZxTklTaHM0akpJUzhja2pETHJOS0owMzd4eVk1UTVNQUpvdlVxVWM
Best Regards!
0
0