Complicated MS Access Greatest-N-Per-Group problem

前端 未结 1 503
借酒劲吻你
借酒劲吻你 2021-01-26 15:20

I am looking to combine the following queries into one, where

  • scouting.jumpGate is integer,
  • scouting.astroLoc is a string,
  • scouting.ownerguild i
相关标签:
1条回答
  • 2021-01-26 16:09

    How about:

    Select  scouting.astroLoc, 
            scouting.galaxy, 
            scouting.jumpGate, 
            scouting.ownerGuild 
    From    galaxy Inner Join 
            scouting On galaxy.[galaxy_ID] = scouting.galaxy 
    WHERE   (scouting.ID) In (
                 Select Top 3 scouting.ID
                 From scouting 
                 Where scouting.galaxy = galaxy.[galaxy_ID] 
                 And scouting.ownerGuild = 'SWARM' 
                 Order By scouting.jumpGate Desc) 
    Order By    scouting.astroLoc Desc, 
                    scouting.jumpGate Desc
    

    Otherwise it seems likely that the top 3 may include some

      where scouting.ownerGuild <> 'SWARM' 
    
    0 讨论(0)
提交回复
热议问题