Discussion:
Converting a query from Access to SQL Server
(too old to reply)
Colm Kavanagh
2013-01-10 20:32:36 UTC
Permalink
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.
Colm Kavanagh
2013-01-10 20:43:33 UTC
Permalink
Please ignore this request. I know how to solve it. Anyone know how/whether I can delete a post?
Erland Sommarskog
2013-01-10 22:23:27 UTC
Permalink
Post by Colm Kavanagh
Please ignore this request. I know how to solve it. Anyone know
how/whether I can delete a post?
This is a Usenet newsgroups, and in theory the NNTP protocol includes a
Cancel command, however many sites do not honour Cancel requests.
--
Erland Sommarskog, SQL Server MVP, ***@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
mcnewsxp
2013-01-14 13:51:02 UTC
Permalink
Post by Colm Kavanagh
Please ignore this request. I know how to solve it. Anyone know how/whether I can delete a post?
you could always describe how you solved it. someone else might benefit.
Continue reading on narkive:
Loading...