Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SO_20171230_SqlServer
CREATE TABLE #Vendas ( VendaID INT IDENTITY(1, 1), EmpresaID INT, ProdutoID INT, Quantidade INT, DataVenda DATE, --Nova coluna com ID de venda por empresa EmpresaVendaID INT, ); --Carregar alguns registos na tabela INSERT INTO #Vendas(EmpresaID, ProdutoID, Quantidade, DataVenda)VALUES (1, 1, 2, '2017-01-01'), (1, 2, 2, '2017-02-01'), (1, 2, 3, '2017-03-01'), (1, 1, 5, '2017-04-01'), (2, 1, 5, '2017-01-01'), (2, 1, 4, '2017-02-01'); SELECT * FROM #Vendas; UPDATE Vd SET EmpresaVendaID = Seq.Sequencia FROM #Vendas Vd INNER JOIN ( SELECT VendaID, ROW_NUMBER() OVER (PARTITION BY EmpresaID ORDER BY VendaID) Sequencia FROM #Vendas ) Seq ON Seq.VendaID = Vd.VendaID ; SELECT * FROM #Vendas;
run
|
edit
|
history
|
help
0
self join
emp 4
Delete double entries from a table without primary key
Joins outside XML element
FIGURA5.2
SQL Server - UK Holiday Calendar Example
megha
Checking SQL Job run status
sql server dynamic 12 month time series and pivot with month year column names
/Users/svetlanakanevskaa/Downloads/ACDB_LIGHT_MS.sql