Identify the SQL that answers each of the following questions: What is the total
ID: 3744870 • Letter: I
Question
Identify the SQL that answers each of the following questions:
What is the total number of scores for each test with a total score of at least 200?
What is the total number of scores for each student with a total score of at least 200?
What is the total number of scores for each student who has taken exactly three tests?
What is the total number of scores for each test that has been taken by exactly 3 students?
What is the average score for each test which has received exactly three scores?
What is the average score for each student with exactly three scores?
What is the lowest score for each test with exactly three scores?
What is the lowest score for each student with exactly three scores?
What is the highest score for each test with exactly three scores?
What is the highest score for each student with exactly three scores?
Explanation / Answer
If you have any doubts, please give me comment...
-- What is the total number of scores for each test with a total score of at least 200?
SELECT TestID, COUNT(Score)
FROM TEST_SCORES
GROUP BY TestID
HAVING SUM(Score) >= 200;
-- What is the total number of scores for each student with a total score of at least 200?
SELECT TestID, COUNT(Score)
FROM TEST_SCORES
GROUP BY StudentID
HAVING SUM(Score) >= 200;
-- What is the total number of scores for each student who has taken exactly three tests?
SELECT TestID, COUNT(Score)
FROM TEST_SCORES
GROUP BY StudentID
HAVING COUNT(Score) = 3;
-- What is the total number of scores for each test that has been taken by exactly 3 students?
SELECT TestID, COUNT(Score)
FROM TEST_SCORES
GROUP BY TestID
HAVING COUNT(Score) = 3;
-- What is the average score for each test which has received exactly three scores?
SELECT TestID, AVG(Score)
FROM TEST_SCORES
GROUP BY TestID
HAVING COUNT(Score) = 3;
-- What is the average score for each student with exactly three scoree?
SELECT TestID, AVG(Score)
FROM TEST_SCORES
GROUP BY StudentID
HAVING COUNT(Score) = 3;
-- What is the lowest score for each test with exactly three scores?
SELECT TestID, MIN(Score)
FROM TEST_SCORES
GROUP BY TestID
HAVING COUNT(Score) = 3;
-- What is the lowest score for each student with exactly three scores?
SELECT TestID, MIN(Score)
FROM TEST_SCORES
GROUP BY StudentID
HAVING COUNT(Score) = 3;
-- What is the highest score for each test with exactly three scores
SELECT TestID, MAX(Score)
FROM TEST_SCORES
GROUP BY TestID
HAVING COUNT(Score) = 3;
-- What is the highest score for each student with exactly three scores?
SELECT TestID, MAX(Score)
FROM TEST_SCORES
GROUP BY StudentID
HAVING COUNT(Score) = 3;