Questão 54 do Concurso Tribunal de Justiça do Estado do Mato Grosso do Sul (TJ-MS) - Tecnologia da Informação (2017)

Dada uma estrutura de variáveis do tipo tabela, conforme abaixo, no SQL Server 2012, com os dados de amostra fornecidos:



  • A SELECT [StockSymbol], [TransactionDate], [StockPrice], LAG([StockPrice]) OVER (PARTITION BY [StockSymbol] ORDER BY [TransactionDate] ASC) AS [PreviousPrice] FROM @StockTransactions ORDER BY [StockSymbol], [TransactionDate]
  • B SELECT [StockSymbol], [TransactionDate], [StockPrice], LAG([StockPrice], 0, NULL) OVER (GROUP BY [StockSymbol] ORDER BY [TransactionDate] ASC) AS [PreviousPrice] FROM @StockTransactions ORDER BY [StockSymbol], [TransactionDate]
  • C SELECT [StockSymbol], [TransactionDate], [StockPrice], LAG([StockPrice]) OVER (ORDER BY [TransactionDate] ASC) AS [PreviousPrice] FROM @StockTransactions GROUP BY [StockSymbol] ORDER BY [StockSymbol], [TransactionDate]
  • D SELECT [StockSymbol], [TransactionDate], [StockPrice], LAG([StockPrice], 0, NULL) OVER (PARTITION BY [StockSymbol] ORDER BY [TransactionDate] ASC) AS [PreviousPrice] FROM @StockTransactions ORDER BY [StockSymbol], [TransactionDate]
  • E SELECT [StockSymbol], [TransactionDate], [StockPrice], LAG([StockPrice]) OVER (GROUP BY [StockSymbol] ORDER BY [TransactionDate] ASC) AS [PreviousPrice] FROM @StockTransactions ORDER BY [StockSymbol], [TransactionDate]