I'm trying to group data from the following three tables to create a new table. the account_no
fields in bmf
and acct_map
are actually drawn from cmf
.
Fields:
bmf: account_no, trans_date
cmf: account_no, balance_due
acct_map: account_no, external_id
The fields I want in my new table are :
external_id, account_no, balance_due
When I use query 1, without the external_id
column, it works fine and populates the data correctly. But when I try query 2, it creates a blank table. Why is this happening?
Query 1:
create table paid as
select bmf.account_no, sum(cmf.balance_due) postpaid_balance
from bmf, cmf
where to_char(bmf.trans_date, 'YYYY MM DD') = '1996 08 14' and
bmf.account_no = cmf.account_no
group by bmf.account_no
Query 2:
create table paid as
select bmf.account_no, sum(cmf.balance_due) postpaid_balance, acct_map.external_id
from bmf, cmf, acct_map
where to_char(bmf.trans_date, 'YYYY MM DD') = '1996 08 14' and
bmf.account_no = cmf.account_no and
acct_map.account_no = bmf.account_no
group by bmf.account_no, acct_map.external_id