Take the 2-minute tour ×

Basically, I'm pulling an array of two numbers out of the DB and I want to get a utilization percentage.

Logic tells me that I want to do this in the business layer, however I'll have to loop through the array to handle it.

I could just as easily throw into the query a

@value1 / @value2 as utilization

What is best practice? What is more efficient?

share|improve this question
It depends on the usage you're doing with the data... –  Bartdude Apr 8 '13 at 12:03
Why would you need to loop through the data in the business layer if you are just dividing one number by another? –  Michael Harmon Apr 8 '13 at 12:06
@MichaelHarmon I'm getting a large data set back, around 100 records. I'd need to loop through them to grab utilization on each. –  Neil M. Apr 8 '13 at 12:10
If that's all you need, let the database handle the work. If you might need the values separately, e.g. to indicate that a sample was too small to be statistically relevant, then return the separate values or both the separate and calculated values. If this is needed by more than one application then centralizing the calculation makes sense. –  HABO Apr 8 '13 at 12:49
add comment


Your Answer



Browse other questions tagged or ask your own question.