select type,count(*) 总次数,sum(维修次数) 维修次数 from (select *,(select count(*) from t2 where 5>time and time>2 and no=t2.no) 维修次数 from t3) tem group by type

解决方案 »

  1.   

    select *
           ,(select count(*) 
               from t2 
              where no in (select no 
                             from T3 
                            where T3.type = t1.type))    
    from t1
      

  2.   

    select *
           ,(select count(*) 
               from t2 
              where no in (select no 
                             from T3 
                            where T3.type = t1.type))    as a
    from t1
    where a .....
      

  3.   

    select *
           ,(select count(*) 
               from t2 
              where no in (select no 
                             from T3 
                            where type = t1.type))  as a
    from t1
    where a .....
      

  4.   

    select t3.type,count(*) as 维修次数 
    from t2,t3
    where t2.no=t3.no
    group by t3.type
    union all
    select 'All' as type,count(*) as 维修次数 
    from t2
      

  5.   

    小干部,加我msn:[email protected],好几次联系你找不到