SQLclassQuiz Final
SQLclassQuiz Final
edu/courses/18457/quizzes/79278/take
Final
Started: May 25 at 5:01pm
Quiz Instructions
The final consists of 30 questions, and covers lessons 1-6. Each question is worth 1 point, for a total
of 30 possible points. Questions 1-11 are true/false; question 12 is a place in the correct order
question; questions 13-27 are multiple choice; and 28-30 are multiple answer questions. Multiple
answer means there may be more than one correct answer to the question. You have to select all the
correct answers to get credit for a multiple answer question.
You have 120 minutes to complete the exam, and it must be completed in one sitting, so make sure
you have 2 hours to focus on the exam before beginning.
Question 1 1 pts
A JOIN and an INNER JOIN perform the same function. INNER is an optional
keyword.
True
False
Question 2 1 pts
True
False
1 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
Question 3 1 pts
True
False
Question 4 1 pts
The DELETE statement is used to remove objects like tables and views from the
database.
True
False
Question 5 1 pts
True
False
Question 6 1 pts
2 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
Management Studio is an effective tool for creating and altering tables in SQL
Server.
True
False
Question 7 1 pts
True
False
Question 8 1 pts
You cannot enter a value into a foreign key column that does not exist in the
associated primary key column.
True
False
Question 9 1 pts
You are not allowed to nest CASE statements inside of one another.
True
3 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
False
Question 10 1 pts
You can use the INTO keyword to dynamically create a table from the result set of
a SELECT statement.
True
False
Question 11 1 pts
When working with aggregate functions any NULL values will be excluded from the
calculated results.
True
False
Question 12 1 pts
The query below is using a 4 part name to identify the table Customer. Match the
part names with their name definitions.
SELECT *
FROM Snickers.Chinook.dbo.Customer
4 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
Snickers Server
Chinook Database
dbo Schema
Customer Object
Question 13 1 pts
5 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
SELECT *
FROM Customer C
LEFT JOIN Invoice I
ON I.CustomerId = C.CustomerId
All rows from Customer will be returned and only those rows in Invoice that have a match.
All rows from Invoice will be returned and only those rows in Customer that have a match.
Only rows that match in both Invoice and Customer will be returned.
Question 14 1 pts
6 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
What is the keyword used in a CASE statement to set the default value when none
of the conditions in the statement evaluate to true.
ELSE
WHEN
AS
SET
Question 15 1 pts
Question 16 1 pts
What statement will remove all of the fax numbers in the Fax column of the
Customer table for customers from Brazil?
7 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
DELETE Fax
FROM Customer
WHERE Country = 'Brazil'
UPDATE Customer
SET Fax = NULL
WHERE Country = 'Brazil'
Question 17 1 pts
Which answer would be the most logical result for the following query:
Allen
Chambers
Marcus
Murray
Norton
Zimmerman
8 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
Question 18 1 pts
Which answer is the proper naming syntax for a local temporary table?
Artist_temp
#Customer
##Invoice
@Genre
Question 19 1 pts
Which of the following queries will return rows from the Playlist table that don't
have any associated PlaylistIds in the PlayListTrack table?
SELECT
P.PlaylistId
,COUNT(PT.PlaylistId) TrackCount
FROM Playlist P
JOIN PlaylistTrack PT
ON P.PlaylistId = PT.PlaylistId
GROUP BY P.PlaylistId
HAVING TrackCount = 0
SELECT
P.PlaylistId
,COUNT(PT.PlaylistId) TrackCount
FROM Playlist P
LEFT JOIN PlaylistTrack PT
ON P.PlaylistId = PT.PlaylistId
9 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
GROUP BY P.PlaylistId
HAVING TrackCount = 0
SELECT
P.PlaylistId
,COUNT(PT.PlaylistId) TrackCount
FROM Playlist P
JOIN PlaylistTrack PT
ON P.PlaylistId = PT.PlaylistId
GROUP BY P.PlaylistId
HAVING COUNT(PT.PlaylistId) = 0
SELECT
P.PlaylistId
,COUNT(PT.PlaylistId) TrackCount
FROM Playlist P
LEFT JOIN PlaylistTrack PT
ON P.PlaylistId = PT.PlaylistId
GROUP BY P.PlaylistId
HAVING COUNT(PT.PlaylistId) = 0
Question 20 1 pts
You need to find all records in a SELECT statement where the birth date is on or
before January 1st 2000 or the birth date value is NULL. The column BirthDate
holds the birth date values. What should your WHERE clause look like?
10 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
Question 21 1 pts
Yes, if you use a different table alias for each instance of the self join.
No.
Question 22 1 pts
What type of JOIN would you use to only return records that exist in both tables?
LEFT JOIN
FULL JOIN
INNER JOIN
RIGHT JOIN
Question 23 1 pts
You want to view the average sales by month on the Invoice table, but only those
months where the average was greater than 6. Which one of these queries will
accomplish the task?
SELECT
11 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
DATENAME(MONTH,InvoiceDate) SalesMonth
,AVG(Total) SalesAverage
FROM Invoice
GROUP BY DATENAME(MONTH,InvoiceDate)
HAVING AVG(Total) > 6
SELECT
DATENAME(MONTH,InvoiceDate) SalesMonth
,AVG(Total) SalesAverage
FROM Invoice
GROUP BY DATENAME(MONTH,InvoiceDate)
WHERE AVG(Total) > 6
SELECT
DATENAME(MONTH,InvoiceDate) SalesMonth
,AVG(Total) SalesAverage
FROM Invoice
GROUP BY InvoiceDate
WHERE AVG(Total) > 6
SELECT
DATENAME(MONTH,InvoiceDate) SalesMonth
,AVG(Total) SalesAverage
FROM Invoice
WHERE AVG(Total) > 6
GROUP BY DATENAME(MONTH,InvoiceDate)
Question 24 1 pts
Which of the following table relationship types requires a linking table between the
parent and child tables?
One to one.
One to many.
Many to Many.
12 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
Question 25 1 pts
CROSS JOIN
FULL JOIN
LEFT JOIN
Question 26 1 pts
Using the query below, I want to return all records from the Artist table that do not
have any records in the Album table. What corrections will I need to make to the
query in order to return the results I want?
SELECT *
FROM Artist A
WHERE EXISTS
(
SELECT *
FROM Album AL
WHERE AL.ArtistId = A.ArtistId
)
Remove the table alias in front of A.ArtistId. A subquery cannot reference an outer query.
13 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
Question 27 1 pts
What is the correct syntax for adding a primary key to the UserID column in the
existing Users table?
Question 28 1 pts
SELECT DISTINCT
BillingCountry
,CASE BillingCountry WHEN 'Canada' THEN 'North America' END
FROM Invoice
SELECT DISTINCT
BillingCountry
14 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
SELECT DISTINCT
BillingCountry
,CASE WHEN BillingCountry = 'Canada' THEN 'North America' ELSE 'N/A' END
FROM Invoice
SELECT DISTINCT
BillingCountry
,CASE WHEN BillingCountry = 'Canada' THEN 'North America' AS 'N/A' END
FROM Invoice
Question 29 1 pts
AVG
MIN
LEN
LTRIM
SUM
COUNT
Question 30 1 pts
Which of the following are valid methods for commenting code in SQL?
15 of 16 5/25/23, 18:48
Quiz: Final https://extcanvas.ucsd.edu/courses/18457/quizzes/79278/take
--COMMENTS GO HERE
//COMMENTS GO HERE
/*
COMMENTS GO HERE
AND HERE
*/
<!--COMMENTS GO HERE-->
16 of 16 5/25/23, 18:48