Each time I run the script it only gives me the MaxDate(Latest date) but a wrong balance figure. what I'm I missing? Here is the code I used;
select CustomerName,MAX(BalanceDate) AS MaxDate,Balance,"Credit Card" AS AccountType
from customer
INNER JOIN creditcardbalance ON customer.ID=creditcardbalance.CustID
group by CustomerName
UNION
SELECT CustomerName,MAX(BalanceDate) AS MaxDate,Balance,"Bond" AS AccountType
from customer
INNER JOIN bondbalance ON customer.ID=bondbalance.CustID
group by CustomerName
order by CustomerName;