Solved

SQL statement won't let add a WHERE. Get an error: Incorrect Syntax Near the Keyword WHERE

Posted on 2012-04-05
5
416 Views
Last Modified: 2012-06-27
SELECT MONTH(start) AS 'Month', location, ID, Event,[Start], [End]
FROM dbo.vw_Events Group By Month(start), location, ID, Event, [Start],[End]
ORDER BY [Start] ASC

When ever I try to add a WHERE, I get an error.

Thanks in advance Experts.
0
Comment
Question by:colonelblue
5 Comments
 
LVL 3

Assisted Solution

by:tobyweston
tobyweston earned 250 total points
ID: 37813289
Where are you putting the "Where" part of the statement?
0
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 250 total points
ID: 37813293
The after the from

SELECT MONTH(start) AS 'Month', location, ID, Event,[Start], [End]
FROM dbo.vw_Events
where ID in (1,2,3)
Group By Month(start), location, ID, Event, [Start],[End]
ORDER BY [Start] ASC
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 37815855
what is the code of vw_Events?
0
 
LVL 32

Expert Comment

by:awking00
ID: 37816313
What does the statment that gives you the error look like?
0
 

Author Closing Comment

by:colonelblue
ID: 37816555
Thank you Experts.<br />I was putting the WHERE after the group and not before as tobyweston and ged325<br />pointed put.<br /><br />You guys rock!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question