Mysql packet Query Highest score

Source: Internet
Author: User

Today, I was told to write a service that was designed to serve each member in accordance with the highest division of the competition in each of the classes, so there are two technical requirements

1 Find the Champions team for each class

2 increase the score of a group of people

From "1", find out the scoring champion team in each class n group, then divide the team score into n parts according to the number of team members, and update the group's score with the method "2".

On the query code!

1 There may be a better way, I reference this article on the Internet,

Http://www.jb51.net/article/31590.htm

Select the Inner JOIN in Method 4, of course, there is a class in two groups of split children and fractions divided by the number of people are not integers, this is not considered in the program logic processing, only to implement the query to achieve the original information.

1 -- query each class's champions team    2  3 from t_mfg_classgamegroup a INNER JOIN (4  56 ona.f_classid = b.f_classid and A.f_score =                            7  

Query results

2 data is simulated.

--ten  where F_uid in (SELECT f_uid from T_mfg_usergroup    WHERE2)

With these two tool statements, you can implement the update

Mysql packet Query Highest score

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.