当前位置: 代码迷 >> Sql Server >> 为什么在这种列里面不行呢,该如何处理
  详细解决方案

为什么在这种列里面不行呢,该如何处理

热度:11   发布时间:2016-04-27 21:23:12.0
为什么在这种列里面不行呢
原因
use   pubs
select     stor_id     ,sum(qty)   as   总订货数量,   count   (distinct   stor_id)   as   客户ID   from   sales     where   stor_id=7131
为什么不行呢?



------解决方案--------------------
select stor_id ,sum(qty) as 总订货数量, count (distinct stor_id) as 客户ID from sales where stor_id=7131
group by stor_id

或者

select sum(qty) as 总订货数量, count (distinct stor_id) as 客户ID from sales where stor_id=7131
------解决方案--------------------
select stor_id ,sum(qty) as 总订货数量, count (distinct stor_id) as 客户ID from sales where stor_id= '7131 '
group by stor_id

------解决方案--------------------
--try

select stor_id ,sum(qty) as 总订货数量, count (distinct stor_id) as 客户ID
from sales
where stor_id= '7131 '
group by stor_id

------解决方案--------------------
--try

select '7131 ' as stor_id,sum(qty) as 总订货数量, count (distinct stor_id) as 客户ID
from sales
where stor_id= '7131 '
  相关解决方案