Colm Kavanagh
2013-01-10 20:32:36 UTC
Tried to convert an Access query into SQL Server query and did the following:
SELECT [MIND Accounts].[Client-id], [MIND Accounts].[Client-name], SUM(Data.[Created transactions (number)]), SUM(Data.[Created refunds (number)]),
Data.[Created transactions (value)] * [Currency conversion].[Conversion rate] AS [Created transactions (EUR value)], Data.[Processing date]
FROM Data INNER JOIN
[Currency conversion] ON Data.Currency = [Currency conversion].Currency INNER JOIN
[MIND Accounts] ON Data.[Merchant CID] = [MIND Accounts].[Account-id]
GROUP BY [MIND Accounts].[Client-id], [MIND Accounts].[Client-name], Data.[Processing date]
HAVING (Data.[Processing date] <= GETDATE() AND Data.[Processing date] >= DATEADD(d, - 27, GETDATE()))
But I get the following error message. How can I correct this? I dont want these fields in the output:
Msg 8120, Level 16, State 1, Line 2
Column 'Data.Created transactions (value)' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8120, Level 16, State 1, Line 2
Column 'Currency conversion.Conversion rate' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
SELECT [MIND Accounts].[Client-id], [MIND Accounts].[Client-name], SUM(Data.[Created transactions (number)]), SUM(Data.[Created refunds (number)]),
Data.[Created transactions (value)] * [Currency conversion].[Conversion rate] AS [Created transactions (EUR value)], Data.[Processing date]
FROM Data INNER JOIN
[Currency conversion] ON Data.Currency = [Currency conversion].Currency INNER JOIN
[MIND Accounts] ON Data.[Merchant CID] = [MIND Accounts].[Account-id]
GROUP BY [MIND Accounts].[Client-id], [MIND Accounts].[Client-name], Data.[Processing date]
HAVING (Data.[Processing date] <= GETDATE() AND Data.[Processing date] >= DATEADD(d, - 27, GETDATE()))
But I get the following error message. How can I correct this? I dont want these fields in the output:
Msg 8120, Level 16, State 1, Line 2
Column 'Data.Created transactions (value)' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8120, Level 16, State 1, Line 2
Column 'Currency conversion.Conversion rate' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.