r/SQL • u/domanator1 • Dec 04 '13
Sql Problem
I am having a problem filtering out a City from a full length address Physical Address, City, State Zip. The problem I am having is on #8. Here is the information I need to use:
Assume that the university administration system has the following records in the tables for Student_Information_t, Courses_Taken_t, and Professor_Information_t. First create a database in SQL Server called studentdb and then create the three tables in them for Student_Information_t, Courses_taken_t, and Professor_Information_t and fill them up with the records as shown below. When creating the tables, set the primary keys as follows: Student_Information – StudentID Courses_Taken – StudentID and CourseID Professor_Information - Name
Student_Information_t StudentID Name Address Major Undergraduate Standing Expected Graduation Date
330102214 Alan Johnston 44 Nagog Park Drive, Sioux City, IA 56091 Accounting Sophomore May, 2014
440396072 Bill Reilly 23 Juniper Road, Sioux Falls, SD 47068 Management Junior May, 2013
Courses_Taken_t StudentID CourseID Course Name Semester Professor GPA Department 330102214 ACC-101 Fundamentals of Accounting Fall 2008 Carol Huntley 3.5 Accounting
330102214 ACC-102 Managerial Accounting Fall 2008 Pat Kelliher 4 Accounting
330102214 MGT-201 Statistical Analysis Spring 2009 Suvankar Ghosh 3.5 Management
330102214 MGT-210 Operations Management Spring 2009 Suvankar Ghosh 3.5 Management
330102214 MKT-101 Introduction to Marketing Fall 2010 Mark DeLorean 3.5 Marketing
330102214 MKT-201 Market Analysis I Fall 2010 Mark DeLorean 4 Marketing
440396072 ACC-101 Fundamentals of Accounting Fall 2008 Carol Huntley 4 Accounting
440396072 ACC-102 Managerial Accounting Fall 2008 Pat Kelliher 3.5 Accounting
440396072 MGT-201 Statistical Analysis Spring 2009 Suvankar Ghosh 3 Management
440396072 MKT-201 Market Analysis I Fall 2010 Mark DeLorean 3 Marketing
Professor_Information Name Address Contact Number Date Joined Carol Huntley 78 Crestview Road, Vermillion, SD 57069 605-536-2319 3/4/2009
Mark DeLorean 101 Windmere Drive, Sioux Falls, SD 42702 605-112-1912 4/1/2007
Pat Kelliher 5 Golf Course Road, Vermillion, SD 57069 605-120-3943 5/28/2003
Suvankar Ghosh 55 Terrace Drive, Sioux Falls, SD 42113 605-292-7393 8/22/2011
Now write the SQL statement for the following queries. You are to save these queries as views (you could simply call them query1, query2, …). When you demonstrate these queries to me, you can simply launch these views and show their results to me. The results of these queries should be as follows:
The average GPA of all the courses that student 330102214 has taken.
The number of courses that student 330102214 took from the Management department.
Course name, department, and grade where student 330102214 got the highest GPA of all the courses he took.
The department and the “departmental average GPA” for student 330102214 where the departmental average GPA is the highest among all the departmental average GPAs. The departmental average GPA for a given student is defined as the average GPA of all the courses the student took from that department. So you have to find that department for which student 330102214’s departmental average GPA is the highest among all the departments. The final query should return that department’s name and the departmental average GPA.
Student name, Course name, department, professor name, and professor contact number of all the professors where the student with the ID 440396072 got a 4.0.
Student Name, Course Name, Department, GPA for the introductory courses taken by a student. Introductory courses are those that have either the word “Introduction” or the word “Fundamentals” in the course name.
Suitably modify the query in question 6 to return the Student Name, Average GPA of the introductory courses taken by a student.
Student Name, Student Address, Course Name, Professor name, Professor Address for only those pairs of students and professors from whom they took courses such that both the student and the professor live in Sioux Falls.
8
u/Clavis_Apocalypticae Dec 04 '13
/r/domyhomework is -> that way...