ITPub博客

首页 > > > SqlServer聚合函数的疑问

SqlServer聚合函数的疑问

作者:petterchx 时间:2019-11-12 11:04:10 0 删除 编辑

create table #Test (id int, price decimal(5,2))

insert into #Test(id, price)

values(1,12.4),(2,10.5)

select sum(price) from #Test with(nolock) where id = 3 --返回null

select sum(price) from #Test with(nolock) where id = 3 group by id --什么也不返回

如上的sql,为什么在分组以后,聚合函数没有任何返回值,而不分组却返回null?经过where过滤后不都没有数据吗?

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4606/viewspace-3129530/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: c++ ,linux ,apache
下一篇: 关于.net发展方向
请登录后发表评论 登录
全部评论

注册时间:2019-10-24

  • 博文量
    131
  • 访问量
    30134