当我DELCARE @qty INT
, 因为我SET qty = ...
和AND q = @qty
我不知道如何纠正那些语法错误!
这里的程序:
CREATE PROCEDURE test(target INT)
BEGIN
DECLARE qty INT
-- Get closest qty
@qty = SELECT q
FROM MH
ORDER BY ABS(@target - q) ASC
LIMIT 1
-- use that "actual" qty in your query
SELECT ((p+m)*((valore+100)/100))
FROM PL
JOIN TV
JOIN MH
WHERE Date = '20130717'
AND End = ''
AND q = @qty
END