Domanda

I'm using OPENQUERY on SQL Server 2008, I have this query:

SELECT * 
FROM OPENQUERY(MyLinkedServer, 'SELECT familyCode, sum(member) FROM customers')

I get this error:

Column familyCode or expression in SELECT list not valid

When I run the code without SUM, it works perfectly:

SELECT * 
FROM OPENQUERY(MyLinkedServer, 'SELECT familyCode, member FROM customers')

What's the correct syntax for including the SUM function?

Thank you!

È stato utile?

Soluzione

you need a group by clause when using an aggregation function like SUM

SELECT familyCode, sum(member) FROM customers group by familyCode
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top