The main query is to determine the main table of the query, and the secondary table.
In this case we can confirm that it is a subquery.
The main table is our student table: Tblstudent can find the student's school number, name
The auxiliary table is the score table, Tblscore
Write your own statement as follows:
SELECTTblstudent. Stuid,tblstudent. Stuname,xuankeshu.kscount,kccj.countscore fromTblstudent, (SELECT Count(Tblscore. CourseID) Kscount,tblscore. Stuid Sidd fromTblscoreGROUP bytblscore.stuid) Xuankeshu,--The number of students selected is found here, grouped by student number(Select sum(Tblscore. Score) Countscore,tblscore. Stuid siddd fromTblscoreGroup bytblscore.stuid) KCCJ--The students ' total scores are identified here, grouped by student's numberwhereTblstudent. Stuid=Xuankeshu.sidd andTblstudent.stuid=Kccj.siddd
The answer is:
Select Stuid,stuname, (SelectCountfromWhere t1.) Stuid=s1. Stuid) selcourses, (SelectSumfromWhere T2. Stuid=s1. STUID) Sumscore from tblstudent S1
Three select directly each one is a piece of data.
50 Query Series-the third query: query all students of the student number, name, number of courses selected, total;