Sorry, this is my first time using this forum. Apparently people can edit my post which although helpful, has taken some information out. I will try to make it more understandable.
I am using SQL Compact 3.5 as a local database. The program is written in VB.NET.
The problem is with querying one of my tables that is taking too long.
The player table has, among other things, id, skill, school, weight, starter.
- idis the player's id
- skillis the player's skill level
- schoolis a foreign key pointing to the id of the school table
- weightis one of 14 different numbers
What I am trying to do is set the starter value = 'true' for the player with the highest skill at a given weight for a given school.
So if there are 100 players at a school, there will be 14 starters, one for each weight.
The player table has 170,000 players, each having 1 of 14 different weights, and each belongs to 1 of 4500 schools.
Someone commented below and showed this statement which appears to be on the right track. I am a novice and have not gotten it implemented quite yet.
  "UPDATE p " &
  "SET starter = 'TRUE' " &
  "FROM player p" &
  "JOIN (" &
  "SELECT DISTINCT school, weight, MAX(skill) AS MaxSkill " &
  "FROM player " &
  "GROUP BY school, weight" &
  ") q ON q.school = p.school AND q.weight = p.weight AND q.MaxSkill =
   p.skill"
 
     
     
    