3 つのテーブルを結合してデータを取得するのが好きです: table1 からの必須フィールド、table2 からの record_count、および table3 からの合計 (金額)
次のクエリを使用しています。
select a.cde,a.name,count(b.TransID) as t_cnt, 
       sum(c.Amt) as c_sumofamt 
from table1 a 
inner join table2 b 
    on a.cde=b.cde 
inner join table3 c 
    on a.cde=c.cde 
where a.Bcde='TVM' GROUP BY a.cde;
注: if (where a.Bcde='TVM') の場合は正常に動作しますが、他の branch_code " Bcde" では動作しません
TVM にはほとんどレコードがありません (わずか 40 レコード)
しかし、私が ( where a.Bcde='CBE') を与えると、それは機能しません - 長い時間がかかり、conn を与えます。エラー。
参考までに、より多くのレコードを持っています:
6000+ records in table1
50000+ records in table2
100000+ records in table3
この状況をどのように処理しますか?貴重なご回答をお待ちしております。
よろしく、センサ。