Which SQL statement correctly retrieves a list of customers from Utah, sorted by last name?
Database Practice Test 1 Review

Quiz
•
Information Technology (IT)
•
11th Grade
•
Hard
Susan Fudge
Used 2+ times
FREE Resource
13 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
SELECT lastname, firstname FROM customers WHERE state = 'UT' ORDER BY lastname;
SELECT lastname, firstname FROM customers ORDER BY lastname WHERE state = 'UT';
SELECT lastname, firstname FROM customers WHERE state = 'UT' GROUP BY lastname;
SELECT lastname, firstname FROM customers ORDER BY lastname;
Answer explanation
The correct SQL statement is 'SELECT lastname, firstname FROM customers WHERE state = 'UT' ORDER BY lastname;'. It filters customers from Utah and sorts them by last name, which is the requirement.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statements about the GROUP BY clause are true?
Yes, No, No
No, Yes, No
Yes, Yes, No
No, No, Yes
Answer explanation
The correct choice is 'No, Yes, No' because the GROUP BY clause is used to group rows that have the same values in specified columns, and it can be used with aggregate functions. The other options do not accurately reflect this.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the issue with the following SQL statement? SELECT LastName, FirstName, COUNT(OrderID) FROM Customers GROUP BY LastName HAVING COUNT(OrderID) >= 5;
The SQL statement is missing a GROUP BY clause for all selected columns.
The HAVING clause is incorrectly used instead of WHERE.
The COUNT function is used incorrectly with non-aggregated columns.
The SQL statement is correct and has no issues.
Answer explanation
The SQL statement is missing a GROUP BY clause for all selected columns. Since both LastName and FirstName are selected, they should be included in the GROUP BY clause to avoid ambiguity in the results.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What would cause a runtime error in the following SQL statement? sql CopyEdit UPDATE Customers SET Status = 'Gold' IF TotalAmount > 10000;
The object type needs to be specified within the UPDATE statement.
The IF clause needs to be at the beginning of the statement.
The IF clause needs to be a WHERE clause.
The statement needs semicolons.
Answer explanation
The SQL statement incorrectly uses an IF clause. In SQL, conditions for updates should be specified using a WHERE clause to filter which records to update. Thus, 'IF TotalAmount > 10000' should be 'WHERE TotalAmount > 10000'.
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which SQL statement allows inserting multiple rows at once using the VALUES keyword?
INSERT INTO table_name VALUES (value1, value2, value3,...);
INSERT INTO table_name SELECT (column1, column2, column3);
INSERT INTO table_name(column1, column2) VALUES (value1a, value1b), (value2a, value2b);
INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...);
Answer explanation
The correct choice, 'INSERT INTO table_name(column1, column2) VALUES (value1a, value1b), (value2a, value2b);', allows inserting multiple rows at once using the VALUES keyword, which is not possible with the other options.
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
A quality control specialist wants to retrieve an orderID after inputting an orderdetailID. Which of the following SQL statements correctly creates the required stored procedure?
CREATE PROCEDURE uspGetOrderID @orderdetailIID int, @orderID int OUTPUT BEGIN SELECT @orderID = orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END
CREATE PROCEDURE uspGetOrderID @orderdetailIID int, @orderID int OUTPUT AS BEGIN SELECT orderid FROM orderdetails WHERE orderdetailid = @orderdetailID RETURN @orderID END
CREATE PROCEDURE uspGetOrderID @orderdetailIID int AS BEGIN SELECT orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END
CREATE PROCEDURE uspGetOrderID @orderdetailIID int, @orderID int OUTPUT AS BEGIN SELECT @orderID = orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END
Answer explanation
The correct choice initializes the OUTPUT parameter @orderID with the result of the SELECT statement. It uses the correct syntax with 'BEGIN' and assigns the value directly, ensuring the orderID is retrieved properly.
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the correct SQL statement to create a stored procedure that retrieves an order ID based on the order detail ID?
CREATE PROCEDURE uspGetOrderID @orderdetailID int, @orderID int OUTPUT AS BEGIN SELECT @orderID = orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END
CREATE PROCEDURE uspGetOrderID @orderdetailID int, @orderID int OUTPUT AS BEGIN SELECT orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END
CREATE PROCEDURE uspGetOrderID @orderdetailID int, @orderID int OUTPUT AS BEGIN SELECT @orderID = orderid FROM orderdetails WHERE orderdetailid = @orderdetailID RETURN @orderID END
CREATE PROCEDURE uspGetOrderID @orderdetailID int, @orderID int OUTPUT AS BEGIN SELECT @orderID = orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END
Answer explanation
The correct SQL statement assigns the retrieved order ID to the output parameter @orderID. The other options either do not assign the value or incorrectly use RETURN, which is not suitable for output parameters.
Create a free account and access millions of resources
Similar Resources on Quizizz
11 questions
CBTIS SQL Queries basicos

Quiz
•
11th Grade
10 questions
Bài 22: Thực hành tạo bảng dữ liệu có tham chiếu

Quiz
•
11th Grade
10 questions
BÀI 20. THỰC HÀNH TẠO LẬP CÁC BẢNG CÓ KHÓA NGOÀI

Quiz
•
11th Grade
15 questions
Fundamentos de Bases de Datos

Quiz
•
10th Grade - University
10 questions
Sessioni PHP

Quiz
•
11th Grade
13 questions
Database Practice Test 1 Review

Quiz
•
11th Grade
10 questions
BÀI 19. THỰC HÀNH TẠO LẬP CƠ SỞ DỮ LIỆU VÀ CÁC BẢNG

Quiz
•
11th Grade
14 questions
Teste de SQL: Tabelas e Inserções

Quiz
•
10th Grade - University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade
Discover more resources for Information Technology (IT)
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Taxes

Quiz
•
9th - 12th Grade
17 questions
Parts of Speech

Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression

Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing

Quiz
•
9th - 12th Grade
10 questions
Identifying equations

Quiz
•
KG - University