SQL problem, database crashes.

  • Thread starter Thread starter scubadiver
  • Start date Start date
S

scubadiver

I am trying calculate percentage from month to month for each client group.

The following query is called "monthbal1"

SELECT LiveMonth.MonthID, Account.ClientGrp, LiveMonth.LiveMonth,
Sum(CurBal.CurBal) AS Total
FROM LiveMonth INNER JOIN (Account INNER JOIN CurBal ON Account.ClientCode =
CurBal.ClientCode) ON LiveMonth.MonthID = CurBal.MonthID
WHERE (((Account.StatusID)=2))
GROUP BY LiveMonth.MonthID, Account.ClientGrp, LiveMonth.LiveMonth
ORDER BY Account.ClientGrp;

Followed by "monthbal2":

SELECT monthbal1.MonthID, monthbal1.ClientGrp, monthbal1.LiveMonth,
monthbal1.Total,

(SELECT Max([Total])
FROM monthbal1 AS temp
WHERE temp.ClientGrp = monthbal1.ClientGrp and
temp.monthID=monthbal1.monthID-1)

FROM monthbal1;


Any idea why the DB is crashing?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top