Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7676913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:18:24+00:00 2026-05-31T17:18:24+00:00

Sorry, this is my first time using this forum. Apparently people can edit my

  • 0

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.

  • id is the player’s id
  • skill is the player’s skill level
  • school is a foreign key pointing to the id of the school table
  • weight is 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"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:18:25+00:00Added an answer on May 31, 2026 at 5:18 pm

    Instead of doing a group-by-group, row-by-row approach, this update query does it all at once:

    First, it gathers the highest skill for each school / weight combination.

    It then joins that to the player that has the matching school / weight / skill combination, and then sets that player to the starter.

    UPDATE p
    SET starter = 'TRUE'
    FROM player p 
    JOIN (
        SELECT school, weight, MAX(skill) AS MaxSkill
        FROM player
        GROUP BY school, weight
    ) maxResults 
        ON maxResults.school = p.school 
        AND maxResults.weight = p.weight 
        AND maxResults.MaxSkill = p.skill
    

    However, in the case of a tie in skill, all players with the highest skill would be set to a starter…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time using this site so sorry for any bad formatting
First sorry for my horrible english. This is the first time I'm using backbone.js.
Sorry, this's my first time to ask a question here. So, I don't have
First of all, sorry if this has been asked before. I've done a pretty
First time using this service for a question. I hope I am not asking
first of all sorry if this isn't formatted correctly, first time doing this. I've
Using MVC3 for the first time, so sorry for the noob-like question. I'm trying
this is my first post. I have a huge problem which make me headaches.
EDIT: Solved the problem, thanks to this forum post: http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407 . Thanks everyone! I've
First of all; sorry if this has been asnwered before, I have searched for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.