0% found this document useful (0 votes)
54 views5 pages

Exam Preparation - Part III - SQL

This document provides an exercise on SQL queries with multiple choice and fill-in-the-blank questions. It covers topics like SQL commands for creating and manipulating databases, SQL clauses like SELECT, FROM, WHERE and GROUP BY, aggregate functions, joins, and examples of queries on sample tables.

Uploaded by

Như Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views5 pages

Exam Preparation - Part III - SQL

This document provides an exercise on SQL queries with multiple choice and fill-in-the-blank questions. It covers topics like SQL commands for creating and manipulating databases, SQL clauses like SELECT, FROM, WHERE and GROUP BY, aggregate functions, joins, and examples of queries on sample tables.

Uploaded by

Như Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

 

Databases 
Exercise Sheet III: SQL 
 
1. Multiple Choice 

a) ________ is a set of commands used to control a database, which includes security.   
i.
DCL 
ii.
DPL 
iii.
DML 
iv.DDL 
 
b) The command for creating a database is ________. 
i. CREATE VIEW 
ii. CREATE SCHEMA 
iii. CREATE DATABASE 
iv. CREATE AUTHORIZATION 
 
c) The ________ is the structure that contains descriptions of objects such as tables and 
views created by users.   
i. master view 
ii. catalogue 
iii. SQL  
iv. Schema 
 
d) In an SQL statement, the ________ part states the conditions for row selection? 
i. WHERE 
ii. FROM 
iii. SELECT 
iv. GROUP BY 
 

   

      Page  1 
 
 
e) The following SQL query will produce ________ as a result.  
SELECT SUM (Standard_Price) AS Total_Price  
FROM Product_V  
WHERE Product_Type = 'Wood'; 
i. The total of all products. 
ii. The standard_price of the first wood product in the table. 
iii. The total price of all products that are of type wood. 
iv. The standard_price of any wood product in the table. 
 
f) Multiple values returned from a SQL query that includes an aggregate function are 
called  ________. 
i. Agates 
ii. Vector aggregates 
iii. Summations 
iv. Scalar aggregates 
 
g) What will be returned when the following SQL statement is executed?  
SELECT Driver_No, COUNT (*) AS Num_Deliveries  
FROM Deliveries  
GROUP BY Driver_No; 
 
Solution:  
 
h) The following SQL query will produce ________ as a result. 
SELECT Driver_No, COUNT (*) as Num_Deliveries FROM Deliveries  
 GROUP BY Driver_No  
 HAVING COUNT (*) > 2; 
i. A listing of all drivers who made more than 2 deliveries as well as a count of the 
number of deliveries. 
ii. A listing of all drivers and a count of all drivers. 
iii. A listing of all drivers who made more than 2 deliveries. 
iv. A listing of the number of deliveries greater than 2. 

   

      Page  2 
 
 
i) A join operation:  
i. Brings together data from two different fields.  
ii. Causes two tables with a common domain to be combined into a single table or 
view.  
iii. Causes two disparate tables to be combined into a single table or view.  
iv. Is used to combine indexing operations.  
 
j) The following code is an example of a(n): 
SELECT Customer_T.CustomerID, Order_T.CustomerID, 
CustomerName, OrderID 
FROM Customer_T, Order_T 
WHERE Customer_T.CustomerID = Order_T. CustomerID; 
 
Solution: 
 
k) The following code would include: 
 
SELECT Customer_T.CustomerID,CustomerName, OrderID 
FROM Customer_T RIGHT OUTER JOIN Order_T ON 
Customer_T.CustomerID = Order_T.CustomerID; 
 
i. All rows of the Order_T Table regardless of matches with the Customer_T Table.  
ii. All rows of the Customer_T Table regardless of matches with the Order_T Table.  
iii. Only rows that match both Customer_T and Order_T Tables.  
iv. Only rows that don't match both Customer_T and Order_T Tables.  
 
l) A join that is based upon equality between values in two common columns with the 
same name and where one duplicate column has been removed is called a(n):  
v. equi‐join.  
vi. natural join.  
vii. multivariate join.  
viii. inner join.  

 
 
   

      Page  3 
 
 
2. Northwind Database Queries 
 

 
 

a) What SQL statement lists all customers from the country "Germany"and the city 
"Berlin" from the "Customers" table above? 
 
Solution:  
 

 
 
 
 

b) What SQL statement lists all customers from the country "Germany" and from the 
cities "Marseille" and "London"? 
 
Solution: 
 

 
 
   

      Page  4 
 
 
c) What SQL statement lists all customers from the "Customers" table, sorted 
ascending by the "Country" and descending by the "CustomerName" column? 
 
 

 
 
 

d) What SQL statement creates the above table "Customers" with its seven columns 
CustomerID (Primary Key, INT), CustomerName (VARCHAR, 255), ContactName 
(VARCHAR, 255), Address (VARCHAR, 255), City (VARCHAR, 255), PostalCode 
(VARCHAR, 9) and Country (VARCHAR, 255)?  

Solution:  
 
 
 
 
 
 

 
 
 
e) Create two different forms of the INSERT command to add the first two customers 
to Customer_T. 
 
Solution: 
 

      Page  5 
 

You might also like