表"m":型号     是否卖出     出售人
x1          是         小王
x2          否         小丽
x1          是         晓晓
x3          是        小张怎么查询卖出最多的型号??????sql查询语句怎么写啊各位????????????????????????

解决方案 »

  1.   

    SELECT 型号 ,MAX(NUM) FROM 
    (SELECT 型号,COUNT(*)NUM FROM TB WHERE 是否卖出='是' GROUP BY 型号 ) AS T GROUP BY 型号
      

  2.   


    select count(*) as 数量,型号
    into #k from m
    group by 型号select 型号,数量
    from #k  t
    where not exits(select * from #k where t.数量<数量)
      

  3.   

    select count(*) as 数量,型号
    into #k from m
    where 是否卖出='是' 
    group by 型号select 型号,数量
    from #k  t
    where not exits(select * from #k where t.数量<数量)
      

  4.   

    select top 1 型号
    from tb
    where 是否卖出 ='是'
    group by 型号
    order by count(1) desc
      

  5.   

    SELECT 型号 ,MAX(NUM) as num FROM tb where 是否卖出='是' GROUP BY 型号   order by num desc自己看看吧!
      

  6.   

    TB是什么??用了说TB附近有错误啊~~~~!大侠再次麻烦你一次~~
      

  7.   

    SELECT [NUM]=COUNT(*) FROM TB GROUP BY 型号