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)
 need help with select statement to calculate sum

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-01-20 : 08:15:58
max writes "Im trying to calculate the difference between two columns. The statement im using is:

Select course_name, sum(no_players-players_booked) as no from TEE_TIMES

When I try this statement I get the error message:

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Column 'tee_times_for_sale.ID' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
/golf/csadmin/no.asp, line 14

How can I accomplish this?

Thanks for any help"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-01-20 : 08:19:10
Your error message does not match your query.

Your query will not compile without a GROUP BY clause to accompany your aggregate ... (group by course_name).

Jay White
{0}
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-01-20 : 08:23:23
Select course_name, sum(no_players-players_booked) as no from TEE_TIMES GROUP BY course_name


OS



Go to Top of Page
   

- Advertisement -