私は SQL を学んでいて、解決できない問題に遭遇しました。私を助けてください。Outcome と Income の 2 つのテーブルとデータがあります。テーブルのスクリーンショットを参照してください。 https://www.box.com/s/5c1ah5qi9jg5ty499wvs
これらのテーブルを結合したいのですが、デカルト積のために一部のデータが 2 回追加されています。これが私のコードです:
select o.point, o.date, sum(out), sum(inc) from outcome o left join income i on o.point=i.point and o.date=i.date
group by o.point, o.date
union
select i.point, i.date, sum(out), sum(inc) from income i left join outcome o on o.point=i.point and o.date=i.date
group by i.point, i.date
何かアドバイス?前もって感謝します。
G.