My table (GlAccountAmounts) has the following columns:
SourceID
DateTime
AccountID
AccountClass
AccountClassType
AccountControlAccount
AccountCorporation
AccountCorporationName
AccountDescription
Balance
Credit
Debit
RowUpdateDateTime
I want to show totals for the Debit and Credit columns, by DateTime, for AccountClass = 3 only.
I tried the following query:
SELECT DateTime, AccountID, AccountClass, Credit, Debit
FROM GlAccountAmounts
WHERE AccountClass = 3
GROUP BY DateTime
And I got this error message:
TITLE: Microsoft Report Designer
------------------------------
An error occurred while executing the query.
Column 'GlAccountAmounts.AccountID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
------------------------------
ADDITIONAL INFORMATION:
Column 'GlAccountAmounts.AccountID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (Microsoft SQL Server, Error: 8120)
Can someone please shed some light on what I'm doing wrong here? I'm new at this, and it's rather frustrating...a bit like trying to tell a joke in a foreign langauge.
I'm a real novice at writing queries, so please forgive the "noob" questions...
SourceID
DateTime
AccountID
AccountClass
AccountClassType
AccountControlAccount
AccountCorporation
AccountCorporationName
AccountDescription
Balance
Credit
Debit
RowUpdateDateTime
I want to show totals for the Debit and Credit columns, by DateTime, for AccountClass = 3 only.
I tried the following query:
SELECT DateTime, AccountID, AccountClass, Credit, Debit
FROM GlAccountAmounts
WHERE AccountClass = 3
GROUP BY DateTime
And I got this error message:
TITLE: Microsoft Report Designer
------------------------------
An error occurred while executing the query.
Column 'GlAccountAmounts.AccountID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
------------------------------
ADDITIONAL INFORMATION:
Column 'GlAccountAmounts.AccountID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (Microsoft SQL Server, Error: 8120)
Can someone please shed some light on what I'm doing wrong here? I'm new at this, and it's rather frustrating...a bit like trying to tell a joke in a foreign langauge.
I'm a real novice at writing queries, so please forgive the "noob" questions...