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. General Programming
  3. C#
  4. Detect NULL values before trying to AVG data

Detect NULL values before trying to AVG data

Scheduled Pinned Locked Moved C#
databasesql-serversysadmin
2 Posts 2 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.
  • S Offline
    S Offline
    scjsb
    wrote on last edited by
    #1

    I am trying to calculate the AVG for fields in a SQL SERVER database for a specified time interval. There may be times when there is no data for this interval. What would be the SELECT statement which will not execute the AVG of data if there is no data. I have tried to use "WHERE field IS NOT NULL", but this still throws an exception and stops execution of the program.

    V 1 Reply Last reply
    0
    • S scjsb

      I am trying to calculate the AVG for fields in a SQL SERVER database for a specified time interval. There may be times when there is no data for this interval. What would be the SELECT statement which will not execute the AVG of data if there is no data. I have tried to use "WHERE field IS NOT NULL", but this still throws an exception and stops execution of the program.

      V Offline
      V Offline
      vkuttyp
      wrote on last edited by
      #2

      Instead of where clause use ISNULL(FieldName,'1900-1-1') Good luck

      Kutty

      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