pues realiza un subquery:
Código SQL:
Ver originalSELECT CONVERT(fecha,datetime) AS fecha, t1.* FROM(
SELECT CASE @filtro
WHEN 1 THEN DATEPART(DAY,"Registering Date")
WHEN 2 THEN DATEPART(MONTH,"Registering Date")
WHEN 3 THEN DATEPART(YEAR,"Registering Date")
END AS fecha,
"Location Code", "Zone Code", "Bin Code", "Item No_", SUM("Quantity"),
SUM("Qty_ (Base)")
FROM dbo.[CRONUS España S_A_$Warehouse Entry]
WHERE "Registering Date" BETWEEN '2007-01-01' AND '2008-12-31'
GROUP BY CASE @filtro
WHEN 1 THEN DATEPART(DAY,"Registering Date")
WHEN 2 THEN DATEPART(MONTH,"Registering Date")
WHEN 3 THEN DATEPART(YEAR,"Registering Date")
END,
CASE @filtro
WHEN 1 THEN DATEPART(MONTH,"Registering Date")
WHEN 2 THEN DATEPART(YEAR,"Registering Date")
END,
CASE @filtro
WHEN 1 THEN DATEPART(YEAR,"Registering Date")
END, "Item No_", "Location Code", "Zone Code", "Bin Code"
) AS t1