Ahsan Ul Haq
Ahsan Ul Haq

Reputation: 21

I want to select of sums of amount against specific date and group by some description

My query is

SELECT SUM([CurrentAmount]) AS SUMS, Description 
FROM [PR_ABT] 
WHERE CheckDate = 12/27/2019   
GROUP BY Description

I am getting the following error

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'WHERE'

Upvotes: 0

Views: 26

Answers (1)

marc_s
marc_s

Reputation: 754408

Date as string literal must be in single quotes! And preferably, use the ISO-8601 format YYYYMMDD which is language independent - so try:

SELECT SUM([CurrentAmount]) AS SUMS, Description 
FROM [PR_ABT] 
WHERE CheckDate = '20191227' 
GROUP BY Description

Upvotes: 1

Related Questions