Solved

Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Posted on 2014-09-25
4
206 Views
Last Modified: 2014-09-25
I get an error on the following query.  What seems to be the problem?

DECLARE @fromdt AS datetime 
DECLARE @todt AS datetime
SET @fromdt = '7/1/2014'
SET @todt = '7/31/2014'
select * from tblOrgRegistrations as r 
JOIN tblOrgHours as h
 ON h.RegID = r.regid
 Where r.AgencyID = 74 And (h.ActivityDate >= @fromdt And h.ActivityDate <= @todt)
 Group By r.Agency

Open in new window


Msg 8120, Level 16, State 1, Line 5
Column 'tblOrgRegistrations.RegID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Open in new window

0
Comment
Question by:al4629740
[X]
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
  • 2
4 Comments
 
LVL 69

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 250 total points
ID: 40344486
Remove the GROUP BY; I don't think you need it for this query.
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 250 total points
ID: 40344491
I think you put GROUP BY instead of ORDER BY
0
 

Author Comment

by:al4629740
ID: 40344494
got it
0
 

Author Closing Comment

by:al4629740
ID: 40344495
it was suppose to be order by
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

696 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