Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Gathering Data and Calculating???

Gathering Data and Calculating???

Scheduled Pinned Locked Moved Database
databasehelpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nit115
    wrote on last edited by
    #1

    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.

    E R J 3 Replies Last reply
    0
    • N nit115

      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.

      E Offline
      E Offline
      Edbert P
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • N nit115

        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.

        R Offline
        R Offline
        Rob Graham
        wrote on last edited by
        #3

        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.

        N 1 Reply Last reply
        0
        • R Rob Graham

          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.

          N Offline
          N Offline
          nit115
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • N nit115

            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.

            J Offline
            J Offline
            Jerry Hammond
            wrote on last edited by
            #5

            Use Excel.

            "When I get a little money, I buy books and if any is left, I buy food and clothes." --Erasmus

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups