Sorry I messed up the parens. the actual formula is more complicated, so I decided to hastily take the outer most layers away messing up the formula in the process. MSO = (Per + (AR-sum(Sales))/Sales)
And yes, result should be 2.7 not 2.3. Stupid typo on my part. Thankfully I just got out of a meeting where I was told "it can't be done efficiently" is an acceptable answer at this time.I just need to make sure I'm not missing some obvious way to get the answer out of the data. David ________________________________ From: Igor Tandetnik <itandet...@mvps.org> To: sqlite-users@sqlite.org Sent: Friday, December 16, 2011 4:05 PM Subject: Re: [sqlite] Calculating MSO David Bicking <dbic...@yahoo.com> wrote: > The calculation is that for each customer: > MSO = (Per + (AR-sum(Sales)/Sales)) > > Result > Cust MSO > 000001 2.3 = (3+(100-120)/60)) You have more closing parentheses here than opening ones. If we ignore the rightmot closing paren, the grouping of actual numbers doesn't match the grouping of variables in the formula. What is being divided by Sales: sum(Sales) or (AR - sum(Sales)) ? Further, (3+(100-120)/60) == 2.7, not 2.3. Your example doesn't add up. > Hopefully I described that in a meaningful way. Is it possible to do that > efficiently or at all using SQL? I'd bet it is possible (I might take a stab at it once you clarify the problem statement), but I doubt it'd be efficient. -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users