读书人

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

发布时间: 2012-01-20 18:53:53 作者: rapoo

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

读书人网 >SQL Server

热点推荐