我有2个视图,一个持有入站呼叫和其他出站呼叫。我希望我的查询能够加入2个视图,以便每个运营商(目的地名称和始发名称)并排站立和进站。目前我的当前查询重复了一半的连接,在入站下面的例子中。查询加入的2个视图 - 一半正在复制的答案
SELECT i.destinationname, i.volumein as inbound, o.volumeout as outbound,
i.year, i.month
FROM InboundCalls i
inner join OutboundCalls o
on i.destinationname = o.originationname
GROUP BY i.year, i.month, i.destinationname, o.volumeout, i.volumein
DestinationName Inbound Outbound Year Month
Accounts Spare 9 33 2016 8
Accounts Spare 9 9 2016 8
Accounts Spare 9 7 2016 8
Accounts Spare 9 38 2016 8
Accounts Spare 21 33 2016 9
Accounts Spare 21 9 2016 9
Accounts Spare 21 7 2016 9
Accounts Spare 21 38 2016 9
我期待的结果与下面类似,
DestinationName Inbound Outbound Year Month
Accounts Spare 84 210 2016 9
Accounts Spare 12 32 2016 11
Accounts Spare 36 103 2016 10
Steve Jones 36 96 2016 8
Wayne Rooney 162 172 2016 8
Alan Shearer 1 216 2016 9
Alan Shearer 74 82 2016 8
请让我知道,如果这需要澄清。
你是说一行详细说明当天的电话是什么意思?你能发表一个你想要输出看起来像什么的例子吗?目前还不清楚你要求什么。 –