Toad World® Forums

Count_Big usage while taking the sum of a column


#1

Hi, My work is to count the total number of records present in a table based on some where conditon for the purpose of business validation. for this, we have created a procedure which when executed wil fetch the sum of the records for a column. This is executed with the help of cursor which fetches the count column wise and table wise. For few tables i have taken the count succesfully. But For few tbales I am getting arithmetic overflow error. I am lilsting down the metrics i have used. Please let me know how to use the count_big function here to get the count.

  1. SUM(CASE WHEN IS NULL THEN 1 ELSE 0 END)’
  2. SUM(CASE WHEN IS NULL THEN 0 ELSE END)
  3. SUM(CASE WHEN IS NULL THEN 0 ELSE 1 END)