dev-exchange.com logo

dev-exchange.com latest topics RSS feed

Book mark: Add http://www.dev-exchange.com/cms_view_article.php?aid=36&start=0&sid=2539306f3d6a33817f1e51c42a08f5b9 to your delicious account Add http://www.dev-exchange.com/cms_view_article.php?aid=36&start=0&sid=2539306f3d6a33817f1e51c42a08f5b9 to your digg account Add http://www.dev-exchange.com/cms_view_article.php?aid=36&start=0&sid=2539306f3d6a33817f1e51c42a08f5b9 to your blinklist account Add http://www.dev-exchange.com/cms_view_article.php?aid=36&start=0&sid=2539306f3d6a33817f1e51c42a08f5b9 to your reddit account Add http://www.dev-exchange.com/cms_view_article.php?aid=36&start=0&sid=2539306f3d6a33817f1e51c42a08f5b9 to Dzone Add http://www.dev-exchange.com/cms_view_article.php?aid=36&start=0&sid=2539306f3d6a33817f1e51c42a08f5b9 to your furl account Add http://www.dev-exchange.com/cms_view_article.php?aid=36&start=0&sid=2539306f3d6a33817f1e51c42a08f5b9 to your stumble account Add http://www.dev-exchange.com/cms_view_article.php?aid=36&start=0&sid=2539306f3d6a33817f1e51c42a08f5b9 to your Yahoo myweb account
Article Menu
Google
ColdFusion MX
PHP
ASP
ASP.Net
XML-XSLT
JavaScript
SQL Server
AJAX
Android
 


 
Article
MsN
Tech Author

Articles: 7 Comments: 1
 Posted: Thu Jul 17, 2008 12:36 pm

COUNT() aggregate function is used in SQL to calculate the total count of items in a group.
COUNT_BIG() does the same calculation as COUNT() but difference is what they return.
The difference between the two is COUNT_BIG() returns a BigInt data type value And COUNT() return an Int data type.

Count calculates all null values as well in the group count calculation. All the other aggregate functions may exclude the null values in the calculations.

Examples,

Code:
select COUNT(Distinct city) from tablepeople



If you have millions of rows in a table, COUNT() may throw an error message so you can use COUNT_BIG function instead to avoid this data type error.

Code:
select COUNT_BIG(id) from tablepeople



Hope this hint may help someone out there.
Rating: 4.00/5.00 [1]

Comments
Jacobs
Contributing Member
Contributing Member


Joined: 14 Feb 2007
Articles: 2
Comments: 3
 Posted: Thu Jul 17, 2008 12:51 pm  Post subject: Arithmetic overflow error converting expression to data type

thanks for this.

I had an issue with the count function which i sorted using COUNT_BIG () see the details here at:

http://www.dev-exchange.com/viewtopic.php?p=1664
Rating: 0.00/5.00 [0]
 

Page 1 of 1
All times are GMT

Jump to:  
You cannot post articles in this chapter
You cannot edit your articles in this chapter
You cannot delete your articles in this chapter
You cannot rate articles in this chapter

You cannot post comments in this chapter
You cannot edit your comments in this chapter
You cannot delete your comments in this chapter
You cannot rate comments in this chapter


© 2008 dev-exchange.com
Powered by phpBB. Theme DEVPPL.