I am adding a column of my query:
SELECT SEGMENTO, ESTATUS, CONCEPTO, SUM([ENE-20]) AS [ENE-20]
FROM Tabla
GROUP BY CONCEPTO, ESTATUS, SEGMENTO
I need to do the same process only the sum has to be a variable, this is what I have:
DECLARE @TEST NVARCHAR(10)
SET @TEST = '[ENE-20]'
SELECT SEGMENTO, ESTATUS, CONCEPTO, SUM(@TEST) AS [ENE-20]
FROM Tabla
GROUP BY CONCEPTO, ESTATUS, SEGMENTO
But it shows me the following error:
Operand data type nvarchar is invalid for sum operator.