Free Essay

Sql Case

In:

Submitted By
Words 438
Pages 2
MGS 8020 Business Intelligence
Assignment 3

Please use the SQL (in MS Word) to answer the following questions. You may use subquery but all questions need to be completed in ONE SQL. You need to use the following tables (STUDENT and GPA) to answer Q1 – Q4.

[pic]

1. What is the output if you have the following SQL? (10 points) Select * from STUDENT;

Uncondition SQL that lists all the students from the student table with the respective columns. Select * from Student$

2. Please find the average GPA for each student who lives in the following locations: (40 points)
| Atlanta, GA | United States |
| New Orleans, LA |United States |
| Seoul | Korea |

is the CITY in Korea Wasn’t sure which way the question was asking for the average GPA so I did both. Average by the city
SELECT Student$.City, AVG(GPA$.GPA) as 'City GPA'
FROM GPA$ INNER JOIN Student$ ON GPA$.Student_ID = Student$.Student_ID
WHERE Student$.City IN ('Atlanta','New Orleans','Seoul') group by student$.city

Average for the student, who lives in those cities SELECT student$.Student_Name, AVG(GPA$.GPA)
FROM GPA$ INNER JOIN Student$ ON GPA$.Student_ID = Student$.Student_ID WHERE Student$.City IN ('Atlanta','New Orleans','Seoul') group by student$.Student_Name

3. Please find the student (Student ID and Student Name) who has the highest GPA in MGS 8020 (Course Name) in Fall 2006. (25 points) select Student$.Student_ID, Student$.Student_Name from GPA$ INNER JOIN Student$ ON GPA$.Student_ID = Student$.Student_ID where Course_ID ='MGS 8020' and Year = '2006' and Semester = 'Fall' and gpa >= all (select GPA$.GPA from GPA$ where Course_ID = 'MGS 8020') 4. List all the students (Student ID and Student Name) who enrolled in MGS 8020 in Spring 2009 (25 points) select Student$.Student_ID, Student$.Student_Name from GPA$ INNER JOIN Student$ ON GPA$.Student_ID = Student$.Student_ID where Course_ID ='MGS 8020' and Year = '2009' and Semester = 'Spring'

In One SQL Query:

Select * from Student$

SELECT Student$.City, AVG(GPA$.GPA) as 'City GPA'
FROM GPA$ INNER JOIN Student$ ON GPA$.Student_ID = Student$.Student_ID
WHERE Student$.City IN ('Atlanta','New Orleans','Seoul') group by student$.city

SELECT student$.Student_Name, AVG(GPA$.GPA)
FROM GPA$ INNER JOIN Student$ ON GPA$.Student_ID = Student$.Student_ID WHERE Student$.City IN ('Atlanta','New Orleans','Seoul') group by student$.Student_Name

select Student$.Student_ID, Student$.Student_Name from GPA$ INNER JOIN Student$ ON GPA$.Student_ID = Student$.Student_ID where Course_ID ='MGS 8020' and Year = '2006' and Semester = 'Fall' and gpa >= all (select GPA$.GPA from GPA$ where Course_ID = 'MGS 8020')

select Student$.Student_ID, Student$.Student_Name from GPA$ INNER JOIN Student$ ON GPA$.Student_ID = Student$.Student_ID where Course_ID ='MGS 8020' and Year = '2009' and Semester = 'Spring'

Similar Documents

Premium Essay

Paper

...Introduction to Oracle9i: SQL Instructor Guide • Volume 1 40049GC11 Production 1.1 October 2001 D33993 Authors Nancy Greenberg Priya Nathan Copyright © Oracle Corporation, 2000, 2001. All rights reserved. This documentation contains proprietary information of Oracle Corporation. It is provided under a license agreement containing restrictions on use and disclosure and is also protected by copyright law. Reverse engineering of the software is prohibited. If this documentation is delivered to a U.S. Government Agency of the Department of Defense, then it is delivered with Restricted Rights and the following legend is applicable: Restricted Rights Legend Use, duplication or disclosure by the Government is subject to restrictions for commercial computer software and shall be deemed to be Restricted Rights software under Federal law, as set forth in subparagraph (c)(1)(ii) of DFARS 252.227-7013, Rights in Technical Data and Computer Software (October 1988). This material or any portion of it may not be copied in any form or by any means without the express prior written permission of Oracle Corporation. Any other copying is a violation of copyright law and may result in civil and/or criminal penalties. If this documentation is delivered to a U.S. Government Agency not within the Department of Defense, then it is delivered with “Restricted Rights,” as defined in FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987). The information in this document...

Words: 33172 - Pages: 133

Premium Essay

Deep'Z Studio.

...INTRODUCTION SQL is divided into the following  Data Definition Language (DDL)  Data Manipulation Language (DML)  Data Retrieval Language (DRL)  Transaction Control Language (TCL)  Data Control Language (DCL) DDL -- create, alter, drop, truncate, rename DML -- insert, update, delete DRL -- select TCL -- commit, rollback, savepoint DCL -- grant, revoke CREATE TABLE SYNTAX Create table (col1 datatype1, col2 datatype2 …coln datatypen); Ex: SQL> create table student (no number (2), name varchar (10), marks number (3)); INSERT This will be used to insert the records into table. We have two methods to insert.   a) By value method By address method USING VALUE METHOD Syntax: insert into (table_name) values (value1, value2, value3 …. Valuen); © Copy rights are reserved. 2 Ex: SQL> insert into student values (1, ’sudha’, 100); SQL> insert into student values (2, ’saketh’, 200); To insert a new record again you have to type entire insert command, if there are lot of records this will be difficult. This will be avoided by using address method. b) USING ADDRESS METHOD Syntax: insert into (table_name) values (&col1, &col2, &col3 …. &coln); This will prompt you for the values but for every insert you have to use forward slash. Ex: SQL> insert into student values (&no, '&name', &marks); Enter value for no: 1 Enter value for name: Jagan Enter value for marks: 300 old new SQL> 1:...

Words: 42387 - Pages: 170

Premium Essay

Sql & Qbe

...SQL & QBE There are three typical operations that are done in querying databases (relational algebra): (1) Project—select columns [SELECT in SQL] (2) Restrict—select rows [WHERE] (3) Join—select columns and merge on rows that meet conditions [FROM] & [WHERE] Relational algebra is not used in current systems. It is a conceptual/theoretical way to manipulate RDBs. Structured Query Language (SQL) is a widely used language that retrieves and updates data in tables and views (manipulate RDBs). QBE is a user interface that simplifies SQL procedures. Other than some minor syntax differences, SQL is standardized. It is very powerful—i.e. you can do almost anything with data tables that you want. It is also simple to use. SQL is set based—returns a subset of tables referenced. Action queries enable user to change, insert, create, and delete data sets (tables). Selection queries retrieve and display data. Parameter queries prompt for input information. Dynasets are temporary tables that Access uses to store data resulting from a query. Tables must be related if used in a query. Natural join (equijoin or inner join)—most common kind of join. Two tables are joined on the common (join) column. The WHERE (=) statement specifies the join column(s) in which the rows have to match. Outer join (full)—all rows from both tables are included in output table (left and right outer joins would include all rows in one table but only the matches from the other). ...

Words: 1410 - Pages: 6

Premium Essay

Cloud Database Management System

...Cloud Database Management System IS508E group NO.6 project Group NO.6 members: PENG Yu KALAI Kumaraguru KUTTIKKAT VENUGOPAL Sreehari Contents General business case ............................................................................................................... 1 Introduction and problems ....................................................................................................... 1 The existing technology ............................................................................................................ 2 Challenges of Implementation: ................................................................................................. 9 Reference: ............................................................................................................................... 10 General business case Thanks to the successful management, the business of the company expands very fast. However, the database management system cannot withstand the quickly and greatly increased work load, the break-down frequency increases, which make the decision-making efficiency and customer experience drop. The company tries to turn around this bad trend and poses two solutions: one is to update the present DBMS including hardware, software and human resource; the other one is to make use of SQL Azure from Microsoft to set up cloud environment and transfer the DBMS there. After cost analysis, we find that to reach the same efficiency standard, the cost of first...

Words: 3594 - Pages: 15

Premium Essay

Testing

...the basics of SQL. Follow the steps and Oracle will be fun for you. Step 1: Click the Start button, select Programs, then select SecureCRT 3.x. This will open up the quickconnect dialog box of SecureCRT. Select 1. Protocol as: SSH2 2. Hostname: babbage2.cs.iit.edu 3. SSH Server: Standard As depicted in figure below. On clicking connect at this point will bring up another dialog. Select “Accept and Save” to bring up a window asking username and password for Unix. Upon entering valid username and password, you should now see unix bash prompt. Now type just “sqlplus” at bash prompt to connect to Oracle. It will prompt for username and password for oracle. Upon entering valid username and password, you should now see SQL prompt as: SQL> 1 You are now connected to oracle through SQLPlus client installed on Unix Machine (babbage2.cs.iit.edu). Have fun. Also, if you want to find more information on installing oracle on your personal machine, go to www.oracle.com. Remember at SQL> prompt, after every sql command, don’t forget to put a semicolon(;). A SQL statement is the statement that complies with the syntax rule of SQL. A list of SQL statements such as create, delete, insert, select, and update will be frequently used. The SQL*PLUS commands are the auxiliary set of commands that may be only recognized by ORACLE SQL*PLUS. Frequently used commands in ORACLE SQL*PLUS interface are clear, describe, edit, get, help, list, save, spool, and run. To quit and end the SQL*PLUS session...

Words: 1881 - Pages: 8

Premium Essay

Distribution Channel

...which, in some cases, can result in poor performance. For each SQL statement, a database manager application must initiate a separate communication with DB2. To improve application performance, you can create stored procedures that run on your database server. A client application can then simply call the stored procedures to obtain results of the SQL statements that are contained in the procedure. Because the stored procedure runs the SQL statement on the server for you, database performance is improved. In addition, stored procedures can help to centralize business logic. If you make changes to a stored procedure, the changes are immediately available to all client applications that use it. Stored procedures are programs that have the following characteristics: • Contain procedural constructs with SQL statements • Are stored in databases and run on DB2 servers • Can be called by name by an application that is using SQL • Allow an application program to run in two parts: the application on the client and the stored procedure on the server The following figures show how two client applications access a database located on a database server. A client application that does not use stored procedures to access a database can require more network traffic. A client application that takes advantage of a stored procedure can help to reduce network traffic and the number of times the database is accessed. A typical stored procedure contains one or more SQL statements...

Words: 2097 - Pages: 9

Premium Essay

Srs Formate

...INTRODUCTION TO RTO MANAGEMENT In this growing competitive world it is becoming increasingly & absolutely necessary for any organization to streamline all its activities all the way stressing on quality perfection. Quality can be defined as fitness for use at an economical cost while satisfying customer requirements this can be achieved if the organization has the good quality system in which all the medical activities of the hospital are bought in line with operating procedure and guidance. So the RTO management is planned to automate the current manual system. The main aim of the project is to design innovative software, which deals with the RTO management system. The motto of the project is to simplify the job of the administrative people and to render a user-friendly package. The system provides information regarding the RTO application and its status. The tedious jobs such as verifying all the records of the applicant, confirming all the personal details are furnished, submission of qualification documents, driving license, registration details, etc., are done in the most convenient way to the administrator. Also security is being provided in the most proficient way. All the intermediate stages starting from receiving of the application form to revealing the applicant number along with the expiry date of the license are being dealt. Advantages  ⇨ The main purpose of this software is to make RTO automated...

Words: 10261 - Pages: 42

Premium Essay

Assignment 3: Oracle Table and Query

...us get started! First launch the putty application and open the one for our class that we created week one. Sign into Oracle until you reach the prompt that reads SQL>. For this example I am going to use NFL quarterbacks for our table creation. Once you have arrived at the SQL prompt type in the following command line, create table NFLQBS ( , then hit enter, you should see a 2 on the left side, on the following lines we will create the columns. On line 2 type in, Player_Team varchar(30), then hit enter. On line 3 type in Player_Name varchar(30), hit enter again. Then on line 4 type in Player_Number varchar(5); and hit enter. If done correctly it should read, “Table Created”. The picture above shows where we should be. I will now explain a few of the things we just did in detail. First command we used was Create Table, this is used to create the base table that forms the heart of our relational database. The number in parentheses is used to set how many character can be used in that column. Now we will move onto inserting the data into our table. To do this we will use the insert command which allows us to put new records into the table. I will show you how to input one record into the table then I want you to do it five times and five different records. We will use the following command line. At the SQL prompt type in, Insert into NFLQBS (Player_Team, Player_Name, Player_Number) Values (‘Dallas Cowboys’, ‘Tony...

Words: 491 - Pages: 2

Premium Essay

Nt1330 Unit 1 Assignment 1 Application Of Data-Based Information System

...Whenever we develop various applications using ADO.NET, the requirements will be different with these applications with respect to working with data. Sometimes you will only want to display the data on a form, whereas in some cases that data might be needed to pass on to some other company. Whatever operations you do with the data, fundamental concept of data approach in ADO.NET is the same. In ASP.NET, data access from the database is done by making use of the technology ADO.NET. In this section, let us discuss how to access data using ADO.NET technology. ADO.NET does not depend on live connections continuously As we are aware that in traditional client/server applications, components will be connected to a database and it is kept open while the...

Words: 770 - Pages: 4

Premium Essay

Research

...MOBILE STORE MANAGEMENT SYSTEM _______________ A Thesis Presented to the Faculty of San Diego State University _______________ In Partial Fulfillment of the Requirements for the Degree Master of Science in Computer Science _______________ by Park B. Patel Fall 2012 iii Copyright © 2012 by Park B. Patel All Rights Reserved iv DEDICATION Dedicated to My Mother Chetna Patel, Father Bharat Patel, Wife Komal Trivedi And Brother Jatan Patel v ABSTRACT OF THE THESIS Mobile Store Management System by Park B. Patel Master of Science in Computer Science San Diego State University, 2012 The Mobile Store Management System is software which can become the backbone for a billing and inventory system for small organizations. This software provides an uncomplicated system to run mobile stores. This application could be very useful to small organizations. This application is inspired from current pen and paper based store management systems. It will provide an easy and attractive interface so that the user can easily manage and utilize the application. Various other approaches were considered for this application. This application is designed in a way that it will only require a minimum amount of information from the user. The goal was to look for the minimum amount of information that will meet needed requirements. vi TABLE OF CONTENTS PAGE ABSTRACT ................................................................

Words: 10507 - Pages: 43

Premium Essay

Sql Fundamentals Oracle

...Exam Name: Exam Type: Exam Code: Oracle Database: SQL Fundamentals Oracle 1Z0-051 Total Questions 114 Question: 1 Which statement is true regarding the INTERSECT operator? A. It ignores NULL values. B. Reversing the order of the intersected tables alters the result. C. The names of columns in all SELECT statements must be identical. D. The number of columns and data types must be identical for all SELECT statements in the query. Answer: D Question: 2 Which three statements are true regarding the data types in Oracle Database 0g/11g? (Choose three.) A. Only one LONG column can be used per table. B. A TIMESTAMP data type column stores only time values with fractional seconds. C. The BLOB data type column is used to store binary data in an operating system file. D. The minimum column width that can be specified for a VARCHAR2 data type column is one. E. The value for a CHAR data type column is blank-padded to the maximum defined column width. Answer: A, D, E Question: 3 Examine the structure of the PROGRAMS table: Name Null? Type ---------- ------------- --------------PROG_ID NOT NULL NUMBER(3) PROG_COST NUMBER(8,2) START_DATE NOT NULL DATE END_DATE DATE Which two SQL statements would execute successfully? (Choose two.) A. SELECT NVL(ADD_MONTHS(END_DATE,1),SYSDATE) FROM programs; B. SELECT TO_DATE(NVL(SYSDATE-END_DATE,SYSDATE)) FROM programs; C. SELECT NVL(MONTHS_BETWEEN(start_date,end_date),'Ongoing') FROM programs; D. SELECT NVL(TO_CHAR(MONTHS_BETWEEN(start_date,end_date))...

Words: 11884 - Pages: 48

Premium Essay

Sql Database

...dwqwdlqkdmqwkldnqwkldnwkdnwqdldkwd Solutions To Workshop Exercises Chapter 1: SQL and Data 4 Chapter 2: SQL: The Basics 13 Chapter 3: The WHERE and ORDER BY Clauses 20 Chapter 4: Character, Number, and Miscellaneous Functions 27 Chapter 5: Date and Conversion Functions 42 Chapter 6: Aggregate Functions, GROUP BY and HAVING 57 Chapter 7: Equijoins 73 Chapter 8: Subqueries 108 Chapter 9: Set Operators 126 Chapter 10: Complex Joins 137 Chapter 11: Insert, Update, and Delete 164 Chapter 12: Create, Alter, and Drop Tables 178 Chapter 13: Indexes, Sequences, and Views 188 Chapter 14: The Data Dictionary, Scripting, and Reporting 197 Chapter 15: Security 213 Chapter 16: Regular Expressions and Hierarchical Queries 222 Chapter 17: Exploring Data Warehousing Features 235 Chapter 18: SQL Optimization 248 Chapter 1: SQL and Data In this chapter, you learned about data, how data is organized in tables, and how the relationships among the tables are depicted in a schema diagram. Based on your newly acquired knowledge, design a schema diagram based on the fictional ACME Construction Company. Draw on your own work experience to design the following components. 1. Draw boxes for these three tables: EMPLOYEE, POSITION, and DEPARTMENT. Solution: See the solution for Exercise 3. 2. Create at least three columns for each of the tables and designate a primary key for each table. Solution: See the solution for Exercise 3. 3. Create relationships among the...

Words: 6586 - Pages: 27

Premium Essay

Motivation

...DD1334 Databasteknik Laboration 1: SQL Basics Andreas Gustafsson, Hedvig Kjellström, Michael Minock and John Folkesson The purpose of Laboration 1 is to learn how to retrieve rmation stored in relational databases. You will learn 1) how to formulate SQL queries and understand how they apply to the schema and how they are executed; 2) how constraints effect insertions and deletions; 3) about the basics of view, transactions, indices and triggers. The recommended reading for Laboration 1 is that of Lectures 1-7 , particularly Chap 6-8. Laboration Come prepared to the review session! Only one try is allowed – if you fail, you are not allowed to try again until the next lab session. The review will take 10 minutes or less, so have all papers in order. To pass you should have Completed Task 1 with at least 9 of the 10 queries right, completed Task 2 and able to explain why certain actions give errors and other do not, also 8 of the 9 steps should be documented showing you executed them correctly, Task 3 the output file should show that the trigger works as it should. The grade is A if passed when the review when due. See the Lab Grading page in bilda contents for the due dates for the labs and the grading of late assignments. Laboration 1 is intended to take 30h to complete. Computing Environment In this assignment you will use Nestor 2.0. Nestor is KTH’s logic engine (computer) dedicated to hold the databases used in this and other similar courses. Nestor is aptly named after...

Words: 2303 - Pages: 10

Premium Essay

Database Analysis

...Databases are powerful tools that can provide businesses with an edge over the competition. Databases can help keep track of, inventory, billing, payroll, phone numbers, and much more. Databases are essential for almost every company in today's business world. The company that I used to work for custom built their database in-house to suit their business needs. The company uses Oracle, SQL, and Microsoft Access. The company asked me to develop a helpdesk database using SQL and Microsoft Access. The server-based database that the company uses is the Structured Query Language (SQL) Server to run security. One of the draw backs of the server is that it has many security problems that constantly need to be patched. These patches are important to keep integrity of the data and security and should be scheduled to be applied on regular bases. Microsoft Access is a relational database management system which, allows users to create, edit, and maintain sophisticated databases. When developing the helpdesk database I found the wizard to be easy to use and helpful when creating the tables, data entry screens, display screens, and generating reports. The visual capabilities are user friendly and the user does not need to have programming experience. The wizard is an excellent internal tool to help the user with creating data entry forms and display screens. Microsoft Access also has its security problems. Microsoft Access is restricted to how much data can be stored before needing to...

Words: 706 - Pages: 3

Premium Essay

Db Testing

...Testing at the data access layer is the point at which your application communicates with the database. Tests at this level are vital to improve not only your overall test strategy, but also your product’s quality. In this presentation you’ll find out what you need to know to test the SQL database engine, stored procedures, and data views. Find out how to design effective automated tests that exercise the complete database layer of your applications. You’ll learn about the most common and vexing defects related to SQL databases and the best tools available to support your testing efforts. Copyright Sammamish Software Services 2003. All rights Reserved 1 8/26/2004 The Data Access Layer Testing at the data access layer is the point at which your application communicates with the database. ! In this presentation we’ll discuss why tests at this level are vital to improve not only your overall test strategy, but also your product’s quality ! Copyright Sammamish Software Services 2003. All rights reserved. 2 How to design effective automated tests that exercise the complete database layer of your applications. Donation Street demo The most common and vexing defects related to SQL database The best tools available to support your testing efforts. A strong foundation in Structured Query Language is becoming increasingly necessary and even required by some companies in today’s data environments. Many test professionals are...

Words: 5030 - Pages: 21