Share via

Help with error

Fiotomas 116 Reputation points
2021-04-21T12:46:18.19+00:00

Getting this error Msg 102, Level 15, State 1, Line 16
Incorrect syntax near ','.
for the below script and don't know how to solve it. Can anyone help me please?
Thanks,
F.

SELECT
SyncReservations.SourceSiteId,
V_RESV_FORECAST.Session1_Days,
sum(SyncReservations.Charge1stNightGross),
Count(SyncReservations.RoomPickId),
SyncReservations.Adults,
SyncReservations.BookRef
FROM
SyncReservations
INNER JOIN
V_RESV_FORECAST
ON (SyncReservations.BookRef = V_RESV_FORECAST.BookRef
AND SyncReservations.RoomPickId = V_RESV_FORECAST.RoomPickId)
WHERE
(
SyncReservations.BookingStatus <> 102
AND SyncReservations.PackageCode =
(
'SUM_SCH',
'EB_1SES',
'EB_23SES',
'EB_2SES',
'EB_3SES',
'SS_3CONSECUT',
'SS1AND2',
'SS1AND2'
)
AND V_RESV_FORECAST.Session1_Days <> 0
AND cast(SyncReservations.DateArrive AS DATE) <= '07/10/2021 00:0:0'
AND cast(SyncReservations.DateDepart AS DATE) >= '06/13/2021 00:0:0'
AND SyncReservations.GARef IN
(
'PASS2021',
'HHSS2021',
'SWSS2021',
'WBSS2021'
)
)
GROUP BY
SyncReservations.SourceSiteId,
V_RESV_FORECAST.Session1_Days,
SyncReservations.Adults,
SyncReservations.BookRef
SELECT
SyncGroupRoomBlockAllotments.BlockValue,
SyncGroupRoomBlockAllotments.BlockDate,
SyncGroupRoomBlockAllotments.SourceSiteId,
SyncGroupRoomBlockAllotments.BlockRoomType,
SyncGroupRoomBlockAllotments.BlockAdults
FROM
SyncGroupRoomBlockAllotments
WHERE
(
SyncGroupRoomBlockAllotments.GroupRef IN
(
'PASS2021',
'HHSS2021',
'SWSS2021',
'WBSS2021'
)
AND SyncGroupRoomBlockAllotments.BlockDate BETWEEN '06/13/2021 00:0:0' AND '07/10/2021 00:0:0'
)

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

Answer accepted by question author

Olaf Helper 47,621 Reputation points
2021-04-21T13:02:56.647+00:00

AND SyncReservations.PackageCode =
(
'SUM_SCH',
'EB_1SES',
'EB_23SES',

You can not use the equal = operator to compare on more the one scalar value, you have to use the IN operator, see https://learn.microsoft.com/en-us/sql/t-sql/language-elements/in-transact-sql?view=sql-server-ver15

=>

AND SyncReservations.PackageCode IN  
(  
'SUM_SCH',  
'EB_1SES',  
'EB_23SES',  
'EB_2SES',  

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Fiotomas 116 Reputation points
    2021-04-21T13:09:56.873+00:00

    Thanks, seems to be working now.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.