+ 4

Write a query to output the average of Sam's exam scores for the first semester.

Select avg(score) from sam_grades; How can add that the score i sonly for 1 semester?

9th Apr 2021, 1:56 PM
Minju Kim
Minju Kim - avatar
7 ответов
+ 5
select AVG(score) FROM sam_grades where semester = '1';
5th Oct 2021, 7:16 PM
Fatemeh Afsahhosseini
Fatemeh Afsahhosseini - avatar
+ 2
SELECT AVG (score) FROM sam_grades WHERE semester=1;
1st Dec 2022, 11:56 AM
Guy Martial KEYOU
+ 1
Can you share sample data or more detail about the table structure? If sam_grades table had a semester_id field, you could do something like this: Select semester_id, avg(score) from sam_grades group by semester_id; This would be a separate average for each and every semester. If you just want to average only semester 1 and you had a semester_id field, you could filter down to that like this: Select avg(score) from sam_grades where semester_id=1; Since the table name is "sam_grades", it sounds like there are no other student's grades in that table. This means there would be no need to filter with something like username='Sam';
9th Apr 2021, 9:45 PM
Josh Greig
Josh Greig - avatar
+ 1
Thanks :)
17th Jul 2021, 7:19 PM
Irina Iulia Laska BA
Irina Iulia Laska BA - avatar
0
Thats really simple SELECT avg(score) from sam_grades where semester in(1); using sub query we can do
20th May 2021, 7:13 AM
𝑷𝒂𝒓𝒅𝒉𝒖_𝑨𝒍𝒂𝒑𝒂𝒕𝒊`
𝑷𝒂𝒓𝒅𝒉𝒖_𝑨𝒍𝒂𝒑𝒂𝒕𝒊` - avatar
0
SELECT AVG(score) FROM sam_grades WHERE semester=1;
20th Nov 2021, 1:05 PM
Anne Jungers
Anne Jungers - avatar
0
SELECT AVG(score) FROM sam_grades WHERE semester = 1;
18th Jan 2022, 8:35 PM
OLEH MOROZ
OLEH MOROZ - avatar