Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

840 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