我有以下程序
Create procedure Getdatewiseprofitrecord
@Date date
As
Begin
select *into #temptable from(select prof.Productid, SUM(prof.Amount)Amount,SUM(prof.QuantitySold)Quantitysold,SUM(prof.ProfitAmount) from ProfitRecord prof
where prof.Date=@Date
group by Productid)
select temp.*,pro.ProductName from #temptable temp
inner join Productinfo pro on temp.Productid=pro.ProductId
drop table #temptable
End
但我得到incorrect syntax near keyword expecting as,id or...
我无法解决这个问题。
答案 0 :(得分:0)
你可以尝试一下吗?
CREATE PROCEDURE Getdatewiseprofitrecord
@Date DATE
AS
BEGIN
SELECT *
INTO #temptable
FROM (SELECT prof.Productid, SUM(prof.Amount) Amount,SUM(prof.QuantitySold) Quantitysold,SUM(prof.ProfitAmount) ProfitAmount
FROM ProfitRecord prof
WHERE prof.Date = @Date
GROUP BY Productid)
SELECT temp.*,
pro.ProductName
FROM #temptable temp
JOIN Productinfo pro on temp.Productid = pro.ProductId
DROP TABLE #temptable
END