现在显示的是这个效果select 
SupplierCategory as 供应商分类,
Number as 数量
from SupplierInfo,OrderDetail
where OrderDetail.SupplierId=SupplierInfo.SupplierId
and SupplierCategory=5这是我写的查询语句我想请问一下  怎么才能让 相同供应商的数量全部加起来?  

解决方案 »

  1.   

    select  
    SupplierCategory as 供应商分类,
    sum(Number) as 数量
    from SupplierInfo,OrderDetail
    where OrderDetail.SupplierId=SupplierInfo.SupplierId
    and SupplierCategory=5
      

  2.   

    select  
    SupplierCategory as 供应商分类,
    sum(Number) as 数量
    from SupplierInfo,OrderDetail
    where OrderDetail.SupplierId=SupplierInfo.SupplierId
    and SupplierCategory=5
    group by SupplierCategory
      

  3.   

    select SupplierCategory as 供应商分类,sum(Number) as 数量
    from SupplierInfo,OrderDetail
    where OrderDetail.SupplierId=SupplierInfo.SupplierId and SupplierCategory=5
    group by SupplierCategory
      

  4.   

    select 
    SupplierCategory as 供应商分类,
    sum(Number) as 总数量
    from SupplierInfo,OrderDetail
    where OrderDetail.SupplierId=SupplierInfo.SupplierId
    group by SupplierCategory
      

  5.   


    非常感谢你  不过朋友能不能再请教一下
    select 
    SupplierName as 供应商名字,
    SupplierCategory as 供应商分类,
    sum(Number) as 数量
    from SupplierInfo,OrderDetail
    where OrderDetail.SupplierId=SupplierInfo.SupplierId
    and SupplierCategory=5
    group by SupplierName现在这样不行了
    他说我选择列表中的列 'SupplierInfo.SupplierCategory' 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中。  麻烦了 分给你了