Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Cannot use count(*) or group by

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-01-13 : 08:31:18
Louis writes "Whenever I use count(*) or group by in the following query:


select member_id,
company.company_code,
company.credit_limit
system,
member_id,
first_name,
last_name,
members.credit_limit,
members.email,
date_sent,
count(*)
from Company, Members
left outer join Reminders on members.email = reminders.email
group by member_id

I get the following error message:

Server: Msg 8120, Level 16, State 1, Line 1
Column 'Company.company_code' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Server: Msg 8120, Level 16, State 1, Line 1
Column 'Company.credit_limit' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Server: Msg 8120, Level 16, State 1, Line 1


....and so on for each column in the select list.

I've been sitting with this for near two days now.

Any ideas?"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-01-13 : 08:33:31
Ummmmmmm....did you try adding the remaining columns to the GROUP BY clause?

Your FROM clause has problems too. There's no JOIN expression to connect Company and Members tables. Unless you want a cross join between the two, but I don't believe that's what you want.

Go to Top of Page
   

- Advertisement -