简体   繁体   中英

incorrect syntax near keyword select expecting as

i have following procedure

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

but i get incorrect syntax near keyword expecting as,id or...

I could not figure the issue.

Can you try this and see.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM