Sie sind auf Seite 1von 3

Databases

Universidad de Len

Course 2014-2015

Assignment 9. SQL Introduction


In this assignment students will be introduced to the SQL language (Transient SQL) using Microsoft SQL
Server Management Studio. After the assignment, the student should be familiar with the SELECT, ORDER BY and WHERE commands and know all the possibilities that the SQL language offers to retrieve
information from databases .
0. Deliverable
Date: This assignment is due by Monday December 8 at 11:55 PM (debe entregarse ANTES del
lunes 8 de diciembre a las 23:55).
A pdf file named LastName.FirstName.Ass9.SQLIntro.pdf with the script containing all the SQL
sentences evaluated.
Students will use the corresponding task for delivering this assignment.
1. Pubs database
In this assignment we are going to work using the public Pubs database.
1.1 You can download it at:
http://www.microsoft.com/en-us/download/details.aspx?id=23654
1.2 Once the download has finished, you have to execute the SQL2000SampleDb.msi
package, which creates a folder called SQL Server 2000 Sample Databases in your
Hard Drive (C:)
1.3 In order to follow with the Pubs database installation, it is necessary to have an instance
of the SQL Server 2014 Management Studio (SSMS) running.
1.4 In SSMS you have to go to File->Open->File and load the instpubs script located in
the folder created recently. If all works fine, you should have something similar to this
screenshot.

1.5 To run the script, you can click on the Execute ( ! ) button or press F5
1.6 After that in the Object Explorer pane, the pubs database should appear by clicking on
the + button near the Databases folder.

Dpto. Ingeniera Elctrica y de Sistemas y Automtica

Universidad de Len

Databases

Course 2014-2015

Query Window.
2.1 Now that we have correctly installed the pubs database, we need to connect with it.
Clicking on the New Query button, we open a new pane where we can write and run
our sentences.
2.2 Create a sentence using transient SQL to check that our database pubs exists.
2.3 Select the database pubs to work with it.
2.4 Show all the tables names which belonges to pubs database.
2.5 Show the description of the table titles
2.6 Show the type of all the books stored in the table titles
2.7 Show the title and the price of all the books
2.8 Show the title and the price of the books with a valid price.
2.9 Show the last query in descending order.
2.10 Repeat the last query but just showing the business books, adding the alias Business
books to the title column.
2.11 Show the title, the price in dolars and the price in euros of the books with a valid price.
(The price in the table is in dolars and 1$=0.80)
2.12 Show the description of the table sales
2.13 Show all the data available for sales
2.14 Show all the sales done before 15/02/93 (Remember than depending on the language of
your installation, the DATE format can change. By clicking with the right button in the
SQL\SQLEXPRESS icon in the Object Explorer-> Properties you can see the language
of your Server. In USA, the format is MM/DD/YY whereas in Europe is DD/MM/YY)
2.15 Show all the sales done before 15/02/93 with less than 30 books (qty) and all the sales
done after that date with 50 or more.
2.16 Show the description of the table authors
2.17 Show all the data available for authors
2.18 Show all the authors sorted by their state and their city
2.19 Show the au_id, au_lname and au_fname of all the authors whit a phone number which
starts by 415. Change the name of the columns to make it more understandable.
2.20 Show just the phone and the city of all the authors which lives in Gary, Salt Lake City,
Covelo or Berkeley without using OR
2.21 Show all the first name authors that starts with a consonant.
2.22 Show all the first name authors that starts with a vowel.
2.23 Show the first name and last name of employees which have a job level between 100
and 200 sorted by job level in ascending order.

Dpto. Ingeniera Elctrica y de Sistemas y Automtica

Universidad de Len

Databases

Course 2014-2015

2.24 Show the description of the table jobs


2.25 Show all the available jobs for a person with expertise lvl of 112.
2.26 [CHALLENGE] Show the fname, lname and job_lvl of all the employees that can be
selected for a Publisher job order by their job_lvl. You cant use any number in the
query sentence.

Dpto. Ingeniera Elctrica y de Sistemas y Automtica

Das könnte Ihnen auch gefallen