|
看了一下楼主第一个SQL语句,分析如下:
select TB.[Safran acct],TB.[Ocean BU],Acct.Category,sum(TB.Movement)as Movement,sum(TB.[Ending Balance]) as Balance
from ([TB$] inner join [BU$] on [TB$].[Ocean BU]=[BU$].Value) inner join [Acct$] on [TB$].[Safran acct]=[Acct$].Account
group by TB.[Ocean BU],TB.[Safran acct],Acct.Category
橙色部分错误原因,在EXCEL中,不论用MQ还是OLEDB调用SQL,表名必须用[table$]的形式。
红色部分错误原因,表BU中没有Value这个字段名。
根据楼主要求用inner join可写成- select [Safran acct],[Ocean BU],Category,sum(Movement) as Movement,sum([Ending Balance]) as Balance
- from ([TB$] a
- inner join [BU$] b
- on a.[Ocean BU]=b.bu)
- inner join [acct$] c
- on a.[Safran acct]=c.Account
- group by [Ocean BU],[Safran acct],Category
复制代码
[ 本帖最后由 capricorn 于 2010-8-13 10:27 编辑 ] |
|