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. SUM question [solved]

SUM question [solved]

Scheduled Pinned Locked Moved Database
question
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.
  • D Offline
    D Offline
    danyDude
    wrote on last edited by
    #1

    Hy, Supose we have this:

    SELECT SUM(ProdGood) as TotalProduced
    From ProductionData

    Now if ProdGood is defined as int(eger) will SUM(ProdGood) be also integer or will it go to BigInt if the SUM is lager than the largest int? Thanks in advance. Oh, I tried google but nothig relevant came out.

    modified on Sunday, February 28, 2010 2:14 AM

    R M 2 Replies Last reply
    0
    • D danyDude

      Hy, Supose we have this:

      SELECT SUM(ProdGood) as TotalProduced
      From ProductionData

      Now if ProdGood is defined as int(eger) will SUM(ProdGood) be also integer or will it go to BigInt if the SUM is lager than the largest int? Thanks in advance. Oh, I tried google but nothig relevant came out.

      modified on Sunday, February 28, 2010 2:14 AM

      R Offline
      R Offline
      Roger Wright
      wrote on last edited by
      #2

      That's an excellent question! I did some searching and couldn't find a definitive answer, either. Have you tried forcing a too large result using test data yet? It would be worthy of an article to explore this further.

      "A Journey of a Thousand Rest Stops Begins with a Single Movement"

      D 1 Reply Last reply
      0
      • R Roger Wright

        That's an excellent question! I did some searching and couldn't find a definitive answer, either. Have you tried forcing a too large result using test data yet? It would be worthy of an article to explore this further.

        "A Journey of a Thousand Rest Stops Begins with a Single Movement"

        D Offline
        D Offline
        danyDude
        wrote on last edited by
        #3

        I didn't have enough but i created a dummy test table and the output is

        "Msg 8115, Level 16, State 2, Line 1
        Arithmetic overflow error converting expression to data type int."

        So no it does not modify the underling field automatically.

        1 Reply Last reply
        0
        • D danyDude

          Hy, Supose we have this:

          SELECT SUM(ProdGood) as TotalProduced
          From ProductionData

          Now if ProdGood is defined as int(eger) will SUM(ProdGood) be also integer or will it go to BigInt if the SUM is lager than the largest int? Thanks in advance. Oh, I tried google but nothig relevant came out.

          modified on Sunday, February 28, 2010 2:14 AM

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          As you found out the data types do not change to meet the needs of the content. If you think about it this would be a disaster in any system that used even minimal data typing. VB could probably handle it X| Another interesting one is trying to work out the result type when you multiple an integer by a decimal and divide it by a float and add a numeric :wtf:

          Never underestimate the power of human stupidity RAH

          D 1 Reply Last reply
          0
          • M Mycroft Holmes

            As you found out the data types do not change to meet the needs of the content. If you think about it this would be a disaster in any system that used even minimal data typing. VB could probably handle it X| Another interesting one is trying to work out the result type when you multiple an integer by a decimal and divide it by a float and add a numeric :wtf:

            Never underestimate the power of human stupidity RAH

            D Offline
            D Offline
            Dan Mos
            wrote on last edited by
            #5

            I've done it! The Result is of type System.Terror :-D

            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