Question

In: Computer Science

SQL FORMAT (11-13 are completed and correct) -- 11. what are the names of all students...

SQL FORMAT (11-13 are completed and correct)

-- 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?

Solutions

Expert Solution

NOTE : SINCE THERE IS NO SCHEMA OF TABLE PROVIDED THEREFOR THE COLUNM NAMES HAVE BEEN TAKEN TENTATIVELY AND QUERIES MAYNOT EXECUTE DIRECTLY. YOU NEED TO CHNAGE THE COLUMN NAMES AS PER YOUR TABLE SCHEMA.

14. How many B grades have been given to physics majors?

QUERRY : SELECT count(*) from student WHERE dept_name='Physics Major' AND grade='B';

Explanation : In the above query the count function of SQL has been used to count the number of students that are in the department of physics major with a grade B.

15. What is the average total credits of students who have taken CS-319?

QUERRY : SELECT avg(credit) from student where course='CS-319';

Explanation : In the above query the AVG function of SQL has been used to directly calculate the average credit of the student who has taken the course CS-319.

16. What is the average total credits of students who have taken CS-101?

QUERRY : SELECT avg(credit) from student where course='CS-101';

Explanation : In the above query the AVG function of SQL has been used to directly calculate the average credit of the student who has taken the course CS-101.

17. What are the course IDs of courses taught by instructor Katz?

QUERRY : SELECT course_ID from student where instructor='Katz';

Explanation : In the above query the course_ID has been chosen for the subjects that has Katz as their instructor.

18. What are the course IDs of all courses offered by instructor Crick's?

QUERRY : SELECT course_ID from student where instructor='Crick';

Explanation :In the above query the course_ID has been chosen for the subjects that has Crick as their instructor.

19. What is the course_id, semester, and year of sections of computer science courses?

QUERRY : SELECT DISTINCT course_id, semester, year from student WHERE course="Computer Science';

Explanation : Since there must not be any repetition of values the DISTINCT keyword has been used to select only un-repeated values from from the table students that have course computer science.

20. What are the names of students who have taken a class taught by instructor Srinivasan?

QUERRY : SELECT name_student from student where instructor='Srinivasan';

Explanation : The above query gives the name of all the students that have Srinivasan as their instructor.


Related Solutions

Write SQL queries below for each of the following: List the names and cities of all...
Write SQL queries below for each of the following: List the names and cities of all customers List the different states the vendors come from (unique values only, no duplicates) Find the number of customers in California List product names and category descriptions for all products supplied by vendor Proformance List names of all employees who have sold to customer Rachel Patterson
How to display in SQL Server, for example, all the author First Names are FIVE LETTERS...
How to display in SQL Server, for example, all the author First Names are FIVE LETTERS LONG if I have the Author Table. I used the WHERE LENGTH ua_fname=5   This is not returning names with 5 letters. Can someone please suggest to me the correct one?
Write the correct code in SQL 1. What is the name and address of the customer...
Write the correct code in SQL 1. What is the name and address of the customer that placed order 57? 2. Assume there is only one product with the description Cherry End Table. List the names of the raw materials that go into making that product. 3. List the product id, description, and finish of the least expensive products. (Note: A couple of rows show a price of 0. Exclude products with a price of 0 from your query.) 4....
Write the correct code in SQL 1. What is the name and address of the customer...
Write the correct code in SQL 1. What is the name and address of the customer that placed order 57? 2. Assume there is only one product with the description Cherry End Table. List the names of the raw materials that go into making that product. 3. List the product id, description, and finish of the least expensive products. (Note: A couple of rows show a price of 0. Exclude products with a price of 0 from your query.) 4....
Post  one set of solutions with names of all participating students in the group to the Canvas...
Post  one set of solutions with names of all participating students in the group to the Canvas course website. The one file needs to be in either an MS Word format or PDF format Graphs should be neat, clean and well-labeled. “Explanations” and answers should given be given in the form of complete sentences.                                                  One can determine how old a tree is by counting its rings, but that Requires cutting the tree down.  A forester wanted to investigate whether or not...
Which following statement(s) about SAS names is/are correct? Check all that apply. A. A SAS variable...
Which following statement(s) about SAS names is/are correct? Check all that apply. A. A SAS variable name starts with a letter or an underscore and continues with any combination of numbers, letters, or underscores as the same as library reference names and data set names. B. A SAS library references name must be 8 characters or less and begin with a letter or an underscore. C. A SAS data set names are 1 to 32 characters in length and are...
**PLEASE ANSWER ALL SUB-QUESTIONS AND EXPLAIN STEP BY STEP. PLEASE INCLUDE FORMULAE IN CORRECT FORMAT NOT...
**PLEASE ANSWER ALL SUB-QUESTIONS AND EXPLAIN STEP BY STEP. PLEASE INCLUDE FORMULAE IN CORRECT FORMAT NOT COMPUTED VERSIONS, PLEASE INCLUDE NOMENCLATURE FOR ALL FORMULAE USED.THANK YOU!*** Discuss the following in detail: (1) Equimolar counterdiffusion and unimolecular diffusion in liquids (2) For diffusion in liquids between counterdiffusion and unimolecular diffusion which is more commonly observed? Why is this observed?
**PLEASE ANSWER ALL SUB-QUESTIONS AND EXPLAIN STEP BY STEP. PLEASE INCLUDE FORMULAE IN CORRECT FORMAT NOT...
**PLEASE ANSWER ALL SUB-QUESTIONS AND EXPLAIN STEP BY STEP. PLEASE INCLUDE FORMULAE IN CORRECT FORMAT NOT COMPUTED VERSIONS, PLEASE INCLUDE NOMENCLATURE FOR ALL FORMULAE USED.THANK YOU!*** Methyl alcohol and water are brought into contact in such a way that the two components form a layer 1.00 cm thick on top of a 3cm deep layer of water. Both components(water and methyl alcohol) are mutually diffusing into each other at 270C, there is no mixing of water and methyl alcohol and...
Several psychology students are unprepared for a surprise​ true/false test with 13 ​questions, and all of...
Several psychology students are unprepared for a surprise​ true/false test with 13 ​questions, and all of their answers are guesses. a. Find the mean and standard deviation for the number of correct answers for such students. b. Would it be unusual for a student to pass by guessing​ (which requires getting at least 11 correct​ answers)? Why or why​ not?
11) What is a fixed cost? 12) What is a variable cost? 13) Where does the...
11) What is a fixed cost? 12) What is a variable cost? 13) Where does the marginal cost curve intersect the average total cost curve? 14) What will be the impact on the total product of labor curve of an improvement in technology? 15) According to the Law of Diminishing Returns, what happens to total output as more of a variable input is used with fixed resources?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT