Sunteți pe pagina 1din 5

IT201 -Unit 3 Lab

*IMPORTANT NOTES:

1. This lab is due this week. It is highly recommended that you DO NOT start this lab right
before the due date. Start early, ask questions if you need clarification, and come in during
office hours if necessary if you need help.

2. It is recommended to hand this lab in as a team project. Only one team member need
submit the project in Canvas BUT all team members MUST be listed on all copies of the
assignment. I will provide all group comments and grades to each team member. Teams
should consist of at most 5 members. Just list all names at the top of this assignment
worksheet.

3. Download this worksheet and enter all of your responses on this worksheet in red font in
the spaces provided. Upload the completed worksheet to Canvas when done.

NOTE: Type out all your SQL code for each question so it is clearly legible. Often in screen
shots the code editor is too small to accurately decipher an entire SQL script.

Using an empty version of the table IT201Students, described in the Unit 3 slides, do the
following (hand in sql code as well as screenshots of the results):

1. Add the following students to the table using INSERT INTO statements:

sid first last applicationDate gpa creditsEarned

000000777 James Bond 2016-01-01 2.5 20

777777777 Lucky Luciano 2016-10-01 3.5 7

000000003 Russell Wilson 2016-10-03 3.9 55

000000025 Richard Sherman 2016-01-01 4.0 65

000000031 Kam Chancellor 2016-10-04 NULL NULL


Paste a copy of the SQL code used to add the records and a screenshot of the results
of a SELECT query that proves that the records were actually added to the table
-here:
2. Run update queries that changes any NULL gpa or NULL creditsEarned values to zero
(be careful not to overwrite non-NULL values with zero). NOTE: You will have to create
two update queries. First, an update query for gpa and then another separate update query
for creditsEarned.

Paste copy of the SQL code used, screenshots that prove that the updates were run
successfully, and finally the results of a SELECT query that proves that updates
worked:

UPDATE `IT201Student` SET `creditsEarned`= 0 WHERE creditsEarned IS NULL

UPDATE `IT201Student` SET `gpa `= 0 WHERE gpa IS NULL


3. Write an update that subtracts 5 credits from creditsEarned if applicationDate < '2016-10-
03' unless the creditsEarned is already less than 5. If creditsEarned is already less than 5
(and applicationDate < '2016-10-03') then set creditsEarned to zero. (Use two UPDATE
statements -one for creditsEarned >= 5 and another for creditsEarned < 5).

Paste copy of the SQL code used, screenshots that prove that the updates were run
successfully, and finally the results of a SELECT query that proves that updates
worked:
4. Write a select query that displays the lowest gpa for an applicationDate before
10/01/2016. Display first, last, applicationDate, and gpa.(NOTE: format for date values is
a string of the format 'YYYY-MM-DD' where YYYY=year, MM=month, DD=day e.g.
'2016-10-01').

Paste copy of the SQL code used and screenshot of the results:

5. Write a select query that displays the highest gpa for an applicationDate before
10/01/2016. Display first, last, applicationDate, and gpa.

Paste copy of the SQL code used and a screenshot of the results:

S-ar putea să vă placă și