2つのビューに1つの着信コールと1つの着信コールがあります。私は自分のクエリを2つのビューに結合して、各オペレータ(destinationnameとoriginationname)のインバウンドとアウトバウンドが並んでいるようにしたい。現時点では、現在のクエリは結合の半分を複製します。参加の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
明確にする必要がある場合はお知らせください。
その日の通話について詳しく説明している行は何ですか?あなたは出力を見せたいものの例を投稿できますか?あなたが求めているものは不明です。 –