hi
i have this query,and i want use paramate in cte,
i get the error below, what's the problem?
DECLARE @StockDate AS DATETIME
SET @StockDate = (SELECT LastStockDate FROM FullDateStock)
WITH CTE_getData AS
(
SELECT MAX(CurrDate) AS CurrDate,Product
FROM
WHERE CurrDate<@StockDate
GROUP BY Product
)
SELECT * FROM CTE_getData
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.