Last active
September 21, 2021 15:47
-
-
Save brunotdantas/2f6589208bcfa470a8b4ef1b7711c920 to your computer and use it in GitHub Desktop.
[T-SQL] - PIVOT tabela dinâmica SQL T-SQL exemplo #SQL SERVER
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE INTEGRADOR | |
GO | |
SELECT Dia, [Linx Venda] as Linx,[Integ. Venda] as Integrador,[L1 Venda OK] as Protheus, | |
[Linx Venda]-[Integ. Venda] as 'Linx - Integrador', | |
[Integ. Venda]-[L1 Venda OK] as 'Integrador - Protheus', | |
[Linx Venda]-[L1 Venda OK] as 'Linx - Protheus' | |
FROM (select Dia, Origem, QtdDoc from [VW_ConsultaIntegracao] where Dia > GETDATE()-3) as consulta | |
Pivot | |
( | |
sum(QtdDoc) | |
for Origem in ([Integ. Venda],[Linx Venda],[L1 Venda OK]) | |
) | |
as pivotconsulta | |
GO | |
Informação de referência: https://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment