Also consider this one :
select a.Account, IP, AccountName from
(select Account, count(account) IP from table1 group by Account) a
left outer join
(select Account, count(account) AccountName from table2 where flag=1 group by Account) b
on a.Account=b.Account
Attention that the join type is important when some accounts have records in Table2 and doesn't have any in Tabl1.
Hope It Helps.