2.select   商品类别 as 商品分类,count(商品类别)as 个数 from tblname group by 商品类别

解决方案 »

  1.   

    1.select a.商品CD,isnull(b.商品类别,c.商品类别) as 商品类别 
    from a,b,c where a.商品CD=b.商品CD and a.商品CD=c.商品CD
      

  2.   

    select 商品CD,'表B.'+(select 商品类别 from B where B.商品CD=A.商品CD) 商品类别 from A
    union all
    select 商品CD,'表B.'+(select 商品类别 from C where C.商品CD=A.商品CD) 商品类别 from A where A.商品CD not in (select 商品CD from B)
      

  3.   

    2. select 商品分类, count(*) 个数 from tablename group by 商品分类
      

  4.   

    ft,又犯了个小错误
    select 商品CD,'表B.'+(select 商品类别 from B where B.商品CD=A.商品CD) 商品类别 from A
    union all
    select 商品CD,'表C.'+(select 商品类别 from C where C.商品CD=A.商品CD) 商品类别 from A where A.商品CD not in (select 商品CD from B)