Gathering Data and Calculating???
-
I have to gather some info from and database - now the issue comes into play with either coding somethng or writing a extremely difficult query - what to do??? Here is the scenario: Data from a single table. Have to calculate columns(sum) according to to certain criteria and have a total at the bottom. Also have to calculate columns(sum) that subtract from a main column and then sum that column. I am just confused as to which: 1) is eaiser ( as the sytem does not have many users) 2) more efficient 3) which would you guys do (code or sql query)? 4) Is a query even possible? Any suggestions or comments in the right direction would be greatly appreciated. Thank You.
-
I have to gather some info from and database - now the issue comes into play with either coding somethng or writing a extremely difficult query - what to do??? Here is the scenario: Data from a single table. Have to calculate columns(sum) according to to certain criteria and have a total at the bottom. Also have to calculate columns(sum) that subtract from a main column and then sum that column. I am just confused as to which: 1) is eaiser ( as the sytem does not have many users) 2) more efficient 3) which would you guys do (code or sql query)? 4) Is a query even possible? Any suggestions or comments in the right direction would be greatly appreciated. Thank You.
A Stored Procedure should do the trick nicely (and more efficient, as you don't need to bring all those records on the client side except the sums). In your SP, calculate the sum of the main column, calculate the sum of the side columns, and then return the sums that you need through output parameters of the SP.
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin Edbert Sydney, Australia
-
I have to gather some info from and database - now the issue comes into play with either coding somethng or writing a extremely difficult query - what to do??? Here is the scenario: Data from a single table. Have to calculate columns(sum) according to to certain criteria and have a total at the bottom. Also have to calculate columns(sum) that subtract from a main column and then sum that column. I am just confused as to which: 1) is eaiser ( as the sytem does not have many users) 2) more efficient 3) which would you guys do (code or sql query)? 4) Is a query even possible? Any suggestions or comments in the right direction would be greatly appreciated. Thank You.
I would create stored procs to perform the required calculations anbd return the results. SQL server is pretty efficient at calculating aggregates. In any case, this is bound to be more efficient than returning all the raw data over the network, then calculating the results. No matter how much faster your calculation is than SQL servers, it will never make up for the overhead of marshalling all that raw data over the network pipe.
-
I would create stored procs to perform the required calculations anbd return the results. SQL server is pretty efficient at calculating aggregates. In any case, this is bound to be more efficient than returning all the raw data over the network, then calculating the results. No matter how much faster your calculation is than SQL servers, it will never make up for the overhead of marshalling all that raw data over the network pipe.
Only 2 rows have actual data and 4 of them are just either yes (nor) no then calculate from those fileds depending and yes or no across 4 fields and only one field can be yes. Then you sum the row and that column. Sorry to be pest - i am not very good a stored p.
-
I have to gather some info from and database - now the issue comes into play with either coding somethng or writing a extremely difficult query - what to do??? Here is the scenario: Data from a single table. Have to calculate columns(sum) according to to certain criteria and have a total at the bottom. Also have to calculate columns(sum) that subtract from a main column and then sum that column. I am just confused as to which: 1) is eaiser ( as the sytem does not have many users) 2) more efficient 3) which would you guys do (code or sql query)? 4) Is a query even possible? Any suggestions or comments in the right direction would be greatly appreciated. Thank You.
Use Excel.
"When I get a little money, I buy books and if any is left, I buy food and clothes." --Erasmus