2
I’m trying to group the lines by group on sqlserver and as a result I want to:
CICLO | CODFIL | CODITPROD | ROW 1 | 1 | 10 | 1 11 | 1 | 10 | 2 12 | 1 | 10 | 3 1 | 2 | 10 | 1 11 | 2 | 10 | 2 1 | 3 | 11 | 1 11 | 3 | 11 | 2
But mine query get back to me
CICLO | CODFIL | CODITPROD | ROW 1 | 1 | 10 | 1 11 | 1 | 10 | 1 12 | 1 | 10 | 1 1 | 2 | 10 | 1 11 | 2 | 10 | 1 1 | 3 | 11 | 1 11 | 3 | 11 | 1
Follow my query
SELECT CICLO,
CODFIL,
CODITPROD,
DENSE_RANK ()
OVER (PARTITION BY CODFIL, CODITPROD
ORDER BY CODFIL, CODITPROD )
AS ROW
FROM TABELA R WITH (NOLOCK)
Just for general knowledge, dense_rank is from sqlserver https://docs.microsoft.com/pt-br/sql/t-sql/functions/dense-rank-transact-sql?view=sql-server-2017... but in this case row_count does better, thanks :D
– Gabriel Souza