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. Access SUM()

Access SUM()

Scheduled Pinned Locked Moved Database
helpquestioncsharpdatabase
5 Posts 3 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.
  • M Offline
    M Offline
    myNameIsRon
    wrote on last edited by
    #1

    Hi, I'm using an Access database in my C# win application. I need to sum values from two different tables and then subtract one of the SUM values from the other. No problem until I runn into one of the SUM values = null. I need it to return 0 if null is the result of the SUM. What is the best way to handle this... with an IIF? IIF(SUM(OrderTotal) IS NULL,0,SUM(OrderTotal)) ??? Thanks for any help you can give. Ron

    V A 2 Replies Last reply
    0
    • M myNameIsRon

      Hi, I'm using an Access database in my C# win application. I need to sum values from two different tables and then subtract one of the SUM values from the other. No problem until I runn into one of the SUM values = null. I need it to return 0 if null is the result of the SUM. What is the best way to handle this... with an IIF? IIF(SUM(OrderTotal) IS NULL,0,SUM(OrderTotal)) ??? Thanks for any help you can give. Ron

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      http://office.microsoft.com/en-us/access/HA012315151033.aspx[^]

      Vasudevan Deepak Kumar Personal Homepage Tech Gossips

      1 Reply Last reply
      0
      • M myNameIsRon

        Hi, I'm using an Access database in my C# win application. I need to sum values from two different tables and then subtract one of the SUM values from the other. No problem until I runn into one of the SUM values = null. I need it to return 0 if null is the result of the SUM. What is the best way to handle this... with an IIF? IIF(SUM(OrderTotal) IS NULL,0,SUM(OrderTotal)) ??? Thanks for any help you can give. Ron

        A Offline
        A Offline
        andyharman
        wrote on last edited by
        #3

        nz(sum(OrderTotal),0)

        M 1 Reply Last reply
        0
        • A andyharman

          nz(sum(OrderTotal),0)

          M Offline
          M Offline
          myNameIsRon
          wrote on last edited by
          #4

          Thanks andyharman, I tried but it came up with an error so I researched it. Looks like NZ can't be used with SQL OLE DB, just within MS Access program. ron

          A 1 Reply Last reply
          0
          • M myNameIsRon

            Thanks andyharman, I tried but it came up with an error so I researched it. Looks like NZ can't be used with SQL OLE DB, just within MS Access program. ron

            A Offline
            A Offline
            andyharman
            wrote on last edited by
            #5

            If you are using SQL Server then the syntax is: isnull(sum(YourColumn), 0)

            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