Solved

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

Posted on 2012-04-05
5
419 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

749 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