Reputation: 1
I wrote a command in sql server 2014 , the command fails with the following error
select * from View_FirstReport
where Date Between '1392/03/20' and '1392/03/19', Insure_ID = '0', User_ID='2'
Group by insure_id, InsureTitle, status
Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ','.
Upvotes: 0
Views: 58
Reputation: 5398
Try like this,
SELECT insure_id
,InsureTitle
,[STATUS]
FROM View_FirstReport
WHERE [DATE] BETWEEN '13920320'
AND '13920319'
AND Insure_ID = '0'
AND [User_ID] = '2'
GROUP BY insure_id
,InsureTitle
,[STATUS]
This is almost similar to SandeepKumar answer.
Upvotes: 0
Reputation: 1202
You should have to replace your , with and operator and select only those records which you are including in group or MIN , MAX , AVG etc for other columns.
SELECT insure_id, InsureTitle, status FROM View_FirstReport
WHERE Date BETWEEN '1392/03/20' and '1392/03/19'
AND Insure_ID = 0
AND User_ID = 2
GROUP BY insure_id, InsureTitle, status
Upvotes: 0
Reputation: 43876
Replace the ,
in your WHERE
clause with AND
:
SELECT *
FROM View_FirstReport
WHERE
Date Between '1392/03/20' AND '1392/03/19'
AND Insure_ID = '0' AND User_ID='2'
GROUB BY insure_id,InsureTitle,status
A detailed syntax definition of WHERE
can for example be found here.
Upvotes: 1
Reputation: 54212
Use AND
instead of ,
:
SELECT * FROM View_FirstReport
WHERE Date BETWEEN '1392/03/20' and '1392/03/19'
AND Insure_ID = 0
AND User_ID = 2
GROUP BY insure_id, InsureTitle, status
Also, integer columns do not require single quote to surround the values.
Upvotes: 0
Reputation: 3268
You should combine the parts of your query with AND
and OR
.
select
*
from
View_FirstReport
where
Date Between '1392/03/20' and '1392/03/19'
AND Insure_ID = '0'
AND User_ID='2'
Group by insure_id, InsureTitle, status
Upvotes: 1