SQL FORMAT (1-3 and 11-13 are completed and correct)
-- 1. what is the average age of people from China?
select avg(age) from census where native_country ='China';
-- 2. what is the average age of people from Taiwan?
select avg(age) from census where native_country = ‘Taiwan’;
-- 3. which native countries have "land" in their name?
select distinct(native_country) from census where native_country
like '%land$
-- 4. what values of the attribute 'marital_status' appear in the data set? Don't show duplicates.
-- 5. what is the average hours per week of work for people from
France between 18 and 25? (inclusive)
-- 6. which people (show all columns) are from Laos, Cuba, or Peru?
Show only 10 lines.
-- 7. what is the average education years for people having a
native country that is not the US?
-- 8. how many executive managers in the data set?
-- 9. how many executive managers have more than 12 years of
education?
-- 10. how many different native countries are found in the data
set?
-- 11. what are the names of all students who have taken some
course? Don't show duplicates.
select distinct(name) from student where tot_cred > 0;
-- 12. what are the names of departments that offer 4-credit
courses? Don't list duplicates.
select distinct(dept_name) from course where credits=4;
-- 13. What are the names and IDs of all students who have
received an A in a computer science class?
select distinct(name), id from student natural join takes natural
join cours$
-- 14. How many B grades have been given to physics majors?
-- 15. What is the average total credits of students who have taken
CS-319?
-- 16. What is the average total credits of students who have taken
CS-101?
-- 17. What are the course IDs of courses taught by instructor
Katz?
-- 18. What are the course IDs of all courses offered by instructor
Crick's department?
-- 19. What is the course_id, semester, and year of sections of
computer science courses?
-- Don't show duplicates.
-- 20. What are the names of students who have taken a class taught
by instructor Srinivasan?
4. select distinct(marital_status) from census; 5. select avg(hours_per_week) from census where native_country='France' and age>17 and age<26; 6. select * from census where native_country='Laos' or native_country='Cuba' or native_country='Peru' limit=10; 7. select avg(edu_years) from census where not native_country='US'; 8. select count(*) from census where designation='executive manager'; 9. select count(*) from census where designation='executive manager' and edu_years>12; 10. select count (distinct native_country) from census;
Post rest of the questions separately.
Get Answers For Free
Most questions answered within 1 hours.