Search the ID number where the biggest value is located - and - unlimited level classification method with C # and database

xiaoxiao2021-03-06  106

http://dev.9cbs.net/develop/Article/42/Article/43/43093.shtm

http://dev.9cbs.net/Article/42/42709.shtm

My friend has a problem, each has a game, records the first score, after dozens of games, the results are as follows: ID Name Score1 A 882 B 763 C 664 C 905 B 776 A 567 B 77 8 C 679 A 44 ... Of course, there are still many best results, and the best grades are the number ID number, which is the best grade, is like: ID Name score1 a 885 B 774 C 90 I felt like a primary question, put the eyes on the maximum, but then I feel that this focus is on the maximum value, but the maximum value of the ID number. Difficulties: Search for the ID number of the maximum value: Everyone may have a few largest value brain: start thinking about this MAX function: SELECT MAX (Score), [name] group by [name] But this damn How can I also insert a first-line hopes: use a child: SELECT [ID], [Name], Scorefrom Table1 Awhere SCORE IN

(Select Max (B.score) AS MaxScore

From Table1 B

Group by b. [Name]) However, this ID number is still more, the reason is that the search is based on the set of maximum, such as 77 this maximum, may be the maximum of B, but A and C may 77 this number, but not the maximum, so ... victory, finally add a condition, make the Name value in the maximum set, in line with the search Name value, [Name], [Name ], Scorefrom Table1 Awhere SCORE IN

(Select Max (B.score) AS MaxScore

From Table1 B

Group by b. [Name] Having a. [Name] = b. [Name]) results successfully come out [Favorit]

转载请注明原文地址:https://www.9cbs.com/read-104544.html

New Post(0)