Skip to main content
replaced http://data.stackexchange.com/ with https://data.stackexchange.com/
Source Link

Most posts have NULL in the CommentCount field

The CommentCount < 30 clause explicitly filters out rows where CommentCount is NULL. (This is because NULL represents the absence of data so logical operators involving NULL always return false.) Thankfully, SQL flavors offer ways to treat NULL as something else (usually zero):

select isnull(CommentCount, 0), count(*) 
from Posts 
group by isnull(CommentCount, 0)
order by isnull(CommentCount, 0)

This results in a more likely looking distributiondistribution:

Count vs. number of comments (corrected)

What does NULL mean in CommentCount?

By comparing the posts with 0 comments to those with NULL, it seems that the row is created with a null CommentCount field. As comments are added, the field is updated to reflect the number of comments on the post. When comments are removed, the field is decremented. When all comments are removed the field becomes 0. So:

  • NULL—No comments have ever been added to the post.
  • 0—Comments have been added to the post, but they've all been removed.

Most posts have NULL in the CommentCount field

The CommentCount < 30 clause explicitly filters out rows where CommentCount is NULL. (This is because NULL represents the absence of data so logical operators involving NULL always return false.) Thankfully, SQL flavors offer ways to treat NULL as something else (usually zero):

select isnull(CommentCount, 0), count(*) 
from Posts 
group by isnull(CommentCount, 0)
order by isnull(CommentCount, 0)

This results in a more likely looking distribution:

Count vs. number of comments (corrected)

What does NULL mean in CommentCount?

By comparing the posts with 0 comments to those with NULL, it seems that the row is created with a null CommentCount field. As comments are added, the field is updated to reflect the number of comments on the post. When comments are removed, the field is decremented. When all comments are removed the field becomes 0. So:

  • NULL—No comments have ever been added to the post.
  • 0—Comments have been added to the post, but they've all been removed.

Most posts have NULL in the CommentCount field

The CommentCount < 30 clause explicitly filters out rows where CommentCount is NULL. (This is because NULL represents the absence of data so logical operators involving NULL always return false.) Thankfully, SQL flavors offer ways to treat NULL as something else (usually zero):

select isnull(CommentCount, 0), count(*) 
from Posts 
group by isnull(CommentCount, 0)
order by isnull(CommentCount, 0)

This results in a more likely looking distribution:

Count vs. number of comments (corrected)

What does NULL mean in CommentCount?

By comparing the posts with 0 comments to those with NULL, it seems that the row is created with a null CommentCount field. As comments are added, the field is updated to reflect the number of comments on the post. When comments are removed, the field is decremented. When all comments are removed the field becomes 0. So:

  • NULL—No comments have ever been added to the post.
  • 0—Comments have been added to the post, but they've all been removed.
syntax highlighting hint for sql
Source Link

Most posts have NULL in the CommentCount field

The CommentCount < 30 clause explicitly filters out rows where CommentCount is NULL. (This is because NULL represents the absence of data so logical operators involving NULL always return false.) Thankfully, SQL flavors offer ways to treat NULL as something else (usually zero):

select isnull(CommentCount, 0), count(*) 
from Posts 
group by isnull(CommentCount, 0)
order by isnull(CommentCount, 0)
select isnull(CommentCount, 0), count(*) 
from Posts 
group by isnull(CommentCount, 0)
order by isnull(CommentCount, 0)

This results in a more likely looking distribution:

Count vs. number of comments (corrected)

What does NULL mean in CommentCount?

By comparing the posts with 0 comments to those with NULL, it seems that the row is created with a null CommentCount field. As comments are added, the field is updated to reflect the number of comments on the post. When comments are removed, the field is decremented. When all comments are removed the field becomes 0. So:

  • NULL—No comments have ever been added to the post.
  • 0—Comments have been added to the post, but they've all been removed.

Most posts have NULL in the CommentCount field

The CommentCount < 30 clause explicitly filters out rows where CommentCount is NULL. (This is because NULL represents the absence of data so logical operators involving NULL always return false.) Thankfully, SQL flavors offer ways to treat NULL as something else (usually zero):

select isnull(CommentCount, 0), count(*) 
from Posts 
group by isnull(CommentCount, 0)
order by isnull(CommentCount, 0)

This results in a more likely looking distribution:

Count vs. number of comments (corrected)

What does NULL mean in CommentCount?

By comparing the posts with 0 comments to those with NULL, it seems that the row is created with a null CommentCount field. As comments are added, the field is updated to reflect the number of comments on the post. When comments are removed, the field is decremented. When all comments are removed the field becomes 0. So:

  • NULL—No comments have ever been added to the post.
  • 0—Comments have been added to the post, but they've all been removed.

Most posts have NULL in the CommentCount field

The CommentCount < 30 clause explicitly filters out rows where CommentCount is NULL. (This is because NULL represents the absence of data so logical operators involving NULL always return false.) Thankfully, SQL flavors offer ways to treat NULL as something else (usually zero):

select isnull(CommentCount, 0), count(*) 
from Posts 
group by isnull(CommentCount, 0)
order by isnull(CommentCount, 0)

This results in a more likely looking distribution:

Count vs. number of comments (corrected)

What does NULL mean in CommentCount?

By comparing the posts with 0 comments to those with NULL, it seems that the row is created with a null CommentCount field. As comments are added, the field is updated to reflect the number of comments on the post. When comments are removed, the field is decremented. When all comments are removed the field becomes 0. So:

  • NULL—No comments have ever been added to the post.
  • 0—Comments have been added to the post, but they've all been removed.
Source Link
Jon Ericson Staff
  • 79.8k
  • 34
  • 244
  • 344

Most posts have NULL in the CommentCount field

The CommentCount < 30 clause explicitly filters out rows where CommentCount is NULL. (This is because NULL represents the absence of data so logical operators involving NULL always return false.) Thankfully, SQL flavors offer ways to treat NULL as something else (usually zero):

select isnull(CommentCount, 0), count(*) 
from Posts 
group by isnull(CommentCount, 0)
order by isnull(CommentCount, 0)

This results in a more likely looking distribution:

Count vs. number of comments (corrected)

What does NULL mean in CommentCount?

By comparing the posts with 0 comments to those with NULL, it seems that the row is created with a null CommentCount field. As comments are added, the field is updated to reflect the number of comments on the post. When comments are removed, the field is decremented. When all comments are removed the field becomes 0. So:

  • NULL—No comments have ever been added to the post.
  • 0—Comments have been added to the post, but they've all been removed.