尝试按查询分组

时间:2015-05-13 21:39:11

标签: sql ms-access rank

我有这个查询,我试图按位置和等级按最终价值分组。

SELECT qryProspects.[Prospect Name]
       , qryProspects.Position
       , qryProspects.Height
       , qryProspects.Weight
       , qryProspects.College
       , qryProspects.RoundID
       , Round([AvgOfAggregate],2) AS [True Value]
       , Round([AvgOfAggregate]*[Multiplier]*[NeedMultiplier],2) AS [Final Value]
       , qryProspects.ProspectID    
  FROM qryProspects
       INNER JOIN qryCalculations ON qryProspects.ProspectID = qryCalculations.ProspectID;

因此,结果会将所有QB从1分为最高,然后所有RB相同,然后是所有WR等......

任何帮助都非常值得赞赏!

1 个答案:

答案 0 :(得分:0)

使用派生表。试试这个

SELECT [Prospect Name]
       , Position
       , Height
       , Weight
       , College
       , RoundID
       , [True Value]
       , [Final Value]
       , ProspectID
  FROM (SELECT qryProspects.[Prospect Name]
               , qryProspects.Position
               , qryProspects.Height
               , qryProspects.Weight
               , qryProspects.College
               , qryProspects.RoundID
               , Round([AvgOfAggregate],2) AS [True Value]
               , Round([AvgOfAggregate]*[Multiplier]*[NeedMultiplier],2) AS [Final Value]
               , qryProspects.ProspectID    
          FROM qryProspects
               INNER JOIN qryCalculations ON qryProspects.ProspectID = qryCalculations.ProspectID)
    AS QB_ORDER
 GROUP BY Position
 ORDER BY [Final Value]