-
If you are an oracle, you can use the lead analysis function, which is very convenient!
select a.Student ID, AGrade, lead (a.)."Grades",1) over(order by student number) col1,lead(a."Grades",2) over(order by student number) col2,a.Grade, lead (a.)."Grades",1) over(order by student number))+lead(a."Grades",2) over(order by student number))) 3 average.
from count a
order by Student ID.
Show results Student ID Grades col1 col2 average.
6 rows selected.
Handle the table first.
original table select * from count;
Student ID Grades.
Table 2 select student number-1, grade from count;
Student ID-1 grades.
The two tables are linked.
select a.Student ID, AGrades of this student number, BGrades: Next student number grades.
from count a left join ( select student number-1 student number, grade from count) b
on a.Student ID = b"Student ID"
Show results Student ID Current Student ID Grade Next Student Number Grade.
6 rows selected.
Got it? The same is true for the 3 table associations, so I won't repeat them here. Finally, add up the columns and divide by 3
-
select a.Student number, (select top 3 sum(grade) from count where student number》a.Student ID order by student number) as mean into k from count a
First, query the data you want to get and insert it into a table, and then update
update count set average = kMean where student number=kStudent ID
-
Summary. Hello dear and happy to answer your <>
The SQL statement to query the highest score of each course is as follows: select course number, max(grade)as highest score from score group by course number; Query the number of students who have been taken for each course select course number, count(distinct student number)as number of students from score group by course number, I hope this service can help you, you can click on my avatar to follow me, and if you have any questions in the future, you can consult me again, and look forward to serving you again. Wishing you well; Happy life, everything goes well [warm] [warm].
Query the SQL statements of the highest scorer in each course.
Hello dear and happy to answer your <>
The SQL statement to query the highest score of each course is as follows: select course number, max(grade)as highest score from score group by course number; Query the number of students who have been taken for each course select course number, count(distinct student number)as number of students from score group by course number, I hope this service can help you, you can click on my avatar to follow me, and if you have any questions in the future, you can consult me again, and look forward to serving you again. Wishing you well; Happy life, everything goes well [warm] [warm].
SQL searches the highest score and person in each subject Student, there are three fields name, subject, and score, to find out the highest score and person in a subject. ”
3-5 minutes is relatively simple and does not consume much time. >>>More
Topic: Believe in yourself and believe in others.
The mediocre believe in others and doubt themselves; Fools, believe in themselves and reject others; A wise man, believe in himself and believe in others. >>>More
1. I'll give you a strategy for this, you can look at the illustration. >>>More
If someone registers for you, you have to use a different email address...It's better to register yourself with your own email address...... >>>More
The birth permit is now gone, and it has been renamed the Family Planning Service Certificate. It has nothing to do with where the household registration is, just take the marriage certificate to the accounting office of the neighborhood committee (that is, the department in charge of the physical examination on March 1) to get it, and you may have to get some gifts for two months of pregnancy, and he will deduct you from having a miscarriage. >>>More