SQLTeam.com | Weblogs | Forums

Incorrect syntax near ')'

I get the "incorrect syntax near "error"

declare @dateFrom datetime='20191101';
declare @dateTo datetime =cast(getdate() as date);

SELECT
cast(Src_Placed_Store_Id as int) as ShopId
--,Slip_Status_Desc
--,Slip_Folds
--,Placed_Slip_Odds
--,Wh_Product_Type_Desc
,Wh_Product_Desc as Game
,convert(date,Placed_Datetime) as Data
,Sum(PayIn_Amt_TC) as PayIn
,Sum(Handling_Fee_Amt_TC) as HC
,sum(Bet_Amt_TC) as Stake
--,Sum(Potential_Win_Amt) as Potential
,Sum(PaidOut_Amt_TC) as PaidOut
,Sum(Gaming_Tax_Amt_TC) as Tax
,Sum(Win_Amt_TC) as Win
from (
select
Src_Placed_Store_Id ,
Wh_Product_Desc

FROM [F_Slips_Snapshot] where Placed_Datetime>=@dateFrom and Placed_Datetime<=@dateTo
group by Src_Placed_Store_Id,Wh_Product_Desc,Placed_Datetime)

hi you have to give a alias ... then the error will go away !!!!

example:
select from ( select col1 , col2 from abc ) xyz

from (
select Src_Placed_Store_Id ,Wh_Product_Desc
FROM [F_Slips_Snapshot] where Placed_Datetime>=@dateFrom and Placed_Datetime<=@dateTo
group by Src_Placed_Store_Id,Wh_Product_Desc,Placed_Datetime) xyz

Thank you !