1

如何修改此查询以返回 distinctModelsVideoProcessorcolumns ?

SELECT TOP(20) * 
FROM 
   (SELECT 
       [3D_Benchmarks].Id AS BenchmarkId,
       Manufacturer, Model, Slug, VideoProcessor, 
       FPS, CPU 
    FROM 
       [3D_Benchmarks]
   JOIN 
       [3D_Slugs] ON [3D_Benchmarks].Id = [3D_Slugs].BenchmarkId) AS tb 
ORDER BY 
   tb.FPS DESC;
4

1 回答 1

2

基于您的评论的新答案。这会查找 FPS 最高的 20 个 Model+VideoProcessor。对于其中的每一个,它都会选择具有最高 FPS 的行。

select  details.Model
,       details.VideoProcessor
,       details.FPS
,       <add other columns here>
from    (
        select  top 20 b.Model
        ,       VideoProcessor
        from    [3D_Benchmarks] b
        join    [3D_Slugs] s
        on      b.Id = s.BenchmarkId 
        group by
                b.Model
        order by
                max(b.FPS) desc
        ) top20
cross apply
        (
        select  top 1 *
        from    [3D_Benchmarks[ b
        join    [3D_Slugs] s
        on      b.Id = s.BenchmarkId 
        where   b.Model = top20.Model
                and b.VideoProcessor = top20.VideoProcessor
        order by
                b.FPS desc
        ) details
于 2012-05-31T22:59:41.623 回答