原因
use pubs
select  stor_id  ,sum(qty) as 总订货数量, count (distinct stor_id) as 客户ID from sales  where stor_id=7131
为什么不行呢?

解决方案 »

  1.   

    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
      

  2.   

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

  3.   

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

  4.   

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