I like to join 3 tables to get data as:
required fields from table1
and record_count from table2
and sum(amount) from table3
I am using the following query:
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
Note: Its working fine if (where a.Bcde='TVM')
but not with anyother branch_code "Bcde"
TVM is having few records (just 40 records)
But if i give (where a.Bcde='CBE') its not working - taking long time and giving conn. err.
For your information its haivng more records:
6000+ records in table1
50000+ records in table2
100000+ records in table3
How to handle this situation?
Expecting your valuable reply.