1

重複の可能性:
SQL Server で異なる

異なる PokemonId 変数を選択したいのですが、うまくいきません

ここでクエリ

select distinct top 36 
    tblFoundPokemonsOnRoutes.pokemonId,MonsterTotalStats,
    MAX(maxLevel) as maxLevel,
    Case Class WHEN 'Ancient' Then '9' 
      WHEN 'Legendary' Then '8' 
      WHEN 'Zenith' Then '7' 
      WHEN 'Emissary' Then '6' 
      WHEN 'Starter' Then '5' 
      WHEN 'Superior' Then '4' 
      WHEN 'Regular' Then '3' 
      ELSE Class 
    END as Result 
from 
    tblFoundPokemonsOnRoutes 
left join 
    tblPokedex on tblFoundPokemonsOnRoutes.pokemonId = tblPokedex.PokemonId 
where 
    tblFoundPokemonsOnRoutes.routeId in 
          (select routeId from tblRoutes where ZoneNumber = 1) 
group by 
    maxLevel, tblFoundPokemonsOnRoutes.pokemonId, MonsterTotalStats, Class 
order by 
    Result desc, MonsterTotalStats desc

ここで返された結果

ここに画像の説明を入力

答えてくれてありがとう

4

1 に答える 1

1

条項に含めるMaxLevelべきではありません。GroupByこのようにしてください:

select distinct top 36 
    tblFoundPokemonsOnRoutes.pokemonId,MonsterTotalStats,
    MAX(maxLevel) as maxLevel,
    Case Class WHEN 'Ancient' Then '9' 
      WHEN 'Legendary' Then '8' 
      WHEN 'Zenith' Then '7' 
      WHEN 'Emissary' Then '6' 
      WHEN 'Starter' Then '5' 
      WHEN 'Superior' Then '4' 
      WHEN 'Regular' Then '3' 
      ELSE Class 
    END as Result 
from 
    tblFoundPokemonsOnRoutes 
left join 
    tblPokedex on tblFoundPokemonsOnRoutes.pokemonId = tblPokedex.PokemonId 
where 
    tblFoundPokemonsOnRoutes.routeId in 
          (select routeId from tblRoutes where ZoneNumber = 1) 
group by 
     tblFoundPokemonsOnRoutes.pokemonId, MonsterTotalStats, Class 
order by 
    Result desc, MonsterTotalStats desc
于 2012-12-09T05:40:12.157 に答える