?
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
Medium Priority
?
208 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 1000 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 1000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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…
Suggested Courses

800 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