有表如下:
型号  规格  转速  效率  功率 ……
4-73  10    1450  85    100
4-73  10    960   88    96 
4-73  10    580   75    85
6-48  14    1450  78    150
6-48  14    960   80    100
6-48  14    580   85    98
……怎样查询出相同型号、规格中最高效率的所有记录,如:型号  规格  转速  效率  功率 ……
4-73  10    960   88    96 
6-48  14    580   85    98
……
谢谢!

解决方案 »

  1.   

    select 型号, 规格, max(转速), max(效率), max(功率)
    from table
    group by 型号, 规格
      

  2.   

    select 型号,规格,转速,效率,功率 from table1 a 
        where exists (select top 1 from table1 where 型号=a.型号 and 规格=a.规格 order by 功率 desc)
      

  3.   

    select 型号,规格,转速,效率,功率 from table1 a 
        where exists (select top 1 * from table1 where 型号=a.型号 and 规格=a.规格 order by 功率 desc)
      

  4.   

    select 型号,规格,转速,效率,功率 from table as a 
    inner join 
    (select 型号, 规格, max(效率) as col1 from table group by 型号, 规格) as b 
    on a.型号=b.型号 and a.规格=b.规格 and a.效率=b.col1
      

  5.   

    语法错误:
    该特定字段'型号'可以参考SQL语句中FROM子句列表中的多个表。
      

  6.   

    SELECT T0.*
    FROM TAB1 T0 INNER JOIN
              (SELECT T1.型号, T1.规格, MAX(T1.效率) AS 最高效率
             FROM TAB1 T1
             GROUP BY 型号, 规格) T2 ON T0.型号 = T2.型号 AND T0.规格 = T2.规格 AND 
          T0.效率 = T2.最高效率
    ORDER BY T0.型号用你的数据测试通过。(表名称TAB1)