日期:2014-05-19  浏览次数:20488 次

为什么在这种列里面不行呢
原因
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 '