In: Computer Science
I have gotten the answer?
Question 1
Ans - Table name - enrollments
Here you have to return the sum of hours from the table. In SQL there is a function SUM( ) that user to give you sum of particular column.
SELECT SUM (hours) FROM enrollments WHERE class='Math';
This query will return the sum of hours where class is equal to Math.
Question 2
Ans - Table name - enrollments
Here you have to select only that rows that consist class name Biology so for that
SELECT * FROM enrollments WHERE class = 'Biology'
This will return all rows containing class name ' Biology'
Question 3
Ans- Table name - enrollments
Here you have to do same thing as question 2 but you have to select school must be equal to 'Math and Science'
SELECT * FROM enrollments WHERE class = 'Biology' AND school = 'Math and Science'
It will return all that matching rows.
Question 4
Ans - Table name - weather_station and weather_stats
Here you have to join to tables
SELECT * FROM weather_station INNER JOIN weather_stats ON weather_station.id = weather_stats.id;
Here you can use JOIN or INNER JOIN both are same.
Question 5
Ans - Table name - gold_prices
Here you have to calculate average for that there is a function AVG(), you can use that
SELECT AVG(price) FROM gold_prices
GROUP BY month, year
ORDER BY year
This will return your desired result
Question 6
Ans- Table name - weather_stats and weather_station
In this table you have to use Left join or right join as well but it depends to whom you are going to accordingly
SELECT * FROM weather_stats LEFT JOIN weather_station ON weather_stats.id = weather_station.id WHERE weather_stats.month = 1 OR weather_stats.month = 4