SELECT
o.id, o.Name, o.StageName, o.[Type], o.Account__c, o.SalesPerson__c,
o2.AccountId__c,o2.Sales_Person__c, o2.InvoiceDate__c
FROM customers.dbo.sales as o
INNER JOIN customers.dbo.account as a on a.Id = o.AccountId
INNER JOIN
(
Select MAX(Id)Id, AccountId
FROM customers.dbo.order__c
WHERE Sales_Person__c <> NULL
) as o1
INNER JOIN Customers.dbo.Order__c as o2 on o2.Id = o1.Id
WHERE (o.SalesPerson__c = NULL)
AND (o.[Type] = 'Renewal')
AND (o.StageName NOT LIKE 'Closed%')
不知道我做错了什么。我收到以下错误:关键字“Where”附近的语法不正确
我正在尝试获取每个帐户的最新订单。任何帮助将不胜感激。