SQLServerCentral.com / General / Programming / Mathematical Operation / Latest PostsInstantForum.NET v2.9.0SQLServerCentral.comhttp://www.sqlservercentral.com/Forums/notifications@sqlservercentral.comThu, 27 Nov 2014 12:43:15 GMT20RE: Mathematical Operationhttp://www.sqlservercentral.com/Forums/Topic1551533-23-1.aspxPretty sure Tom got the high level description. The problem is - it's so generic, we have no way to provide you with advice on how to implement. Hopefully there is a way to provide SOME detail, enough to point us to that general idea, but keep enough back so you can still protect whatever idea you are trying to build.Mon, 17 Mar 2014 17:23:45 GMTMatt Miller (#4)RE: Mathematical Operationhttp://www.sqlservercentral.com/Forums/Topic1551533-23-1.aspxHi Tom,As I mentioned there are several tables to join and one calculation feeds another table \ calculation. So IMO (if possible) doing all that in one SQL will make it a ugly looking SQL.Breaking it down in multiple lines is ideal from the readability \ maintenance of the calculation.Cheers, BikramSun, 16 Mar 2014 13:27:04 GMTbikram.g.itRE: Mathematical Operationhttp://www.sqlservercentral.com/Forums/Topic1551533-23-1.aspxA lot depends on whether the mathematical operations needed can be performed by queries using aggregates, joins the apply operator, and so on. On what you've told us, there's nothing that says it can't be done with a single SQL statement and equally nothing that says it can be done with multiple operations and loops. As a general rule, it's a good idea to try to aoid using explicity loops (and of course explicit cursors) but there are a few cases where the general rule doesn't actually fit (usually where someone has the schema design screwed up, but some real cases too).Sun, 16 Mar 2014 12:47:21 GMTTomThomsonMathematical Operationhttp://www.sqlservercentral.com/Forums/Topic1551533-23-1.aspxHi,I need to write a stored proc that takes a set of input parameters and then performs mathematical operation referencing several other lookup tables and interim calculation results.The set of input comes from a table - so I need to process all rows in the input table.Will a while loop \ cursor be recommended for this type of operation or not at all?The other option then will be to have several temp tables - as output from joining the lookup tables?Please advise!Thanks,Sat, 15 Mar 2014 19:26:30 GMTbikram.g.it