|
|
| 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. |
|
|
| Comments |
Jacobs 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 |
|
|
| |
Page 1 of 1 |
All times are GMT
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
|
|