0% found this document useful (0 votes)
29 views

04 - ASQL - Quiz1 - SQL Advance 1: Tests & Quizzes

The document provides a quiz on SQL Advance 1 concepts with 20 multiple choice questions. It tests knowledge of SQL clauses like UNION, joins using INNER JOIN and OUTER JOIN, aggregation with GROUP BY and HAVING, and subqueries.

Uploaded by

Nhânn Lee
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)
29 views

04 - ASQL - Quiz1 - SQL Advance 1: Tests & Quizzes

The document provides a quiz on SQL Advance 1 concepts with 20 multiple choice questions. It tests knowledge of SQL clauses like UNION, joins using INNER JOIN and OUTER JOIN, aggregation with GROUP BY and HAVING, and subqueries.

Uploaded by

Nhânn Lee
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/ 8

5/13/2021 campuslink.

admin : HCM21_CPL_JAVA_05 : Tests & Quizzes

HCM21_CPL_JAVA_05    Tests & Quizzes

Tests & Quizzes

04_ASQL_Quiz1_SQL Advance 1
Show Feedback | Table of Contents

Part 1 of 1 -

Question 1 of 20
With the UNION clause, each query involved must output the same number of columns, and they 5.0 Points
must be UNION compatible.

True
False
Reset Selection

Question 2 of 20
You are a developer for a Microsoft SQL Server database instance used to support a customer 5.0 Points
service application. You create tables named complaint, customer, and product as follows:

CREATE TABLE [dbo].[complaint] ([ComplaintID] [int], [ProductID] [int], [CustomerID] [int], [ComplaintDate]
[datetime]);

CREATE TABLE [dbo].[customer] ([CustomerID] [int], [CustomerName] [varchar](100), [Address] [varchar]


(200), [City] [varchar](100), [State] [varchar](50), [ZipCode] [varchar](5));

CREATE TABLE [dbo].[product] ([ProductID] [int], [ProductName] [varchar](100), [SalePrice] [money],


[ManufacturerName] [varchar](100));

You need to write a query to identify all customers who have complained about products that have an average
sales price of 500 or more from September 01, 2011.

Which SQL query should you use?

A. "SELECT c.CustomerName,COUNT(com.ComplaintID) AS Complaints


FROM customer c
INNER JOIN complaint com ON c.CustomerID = com.CustomerID
WHERE COUNT(com.ComplaintID) > 10
GROUP BY c.CustomerName;
"

https://gst.fsoft.com.vn/portal/site/b0d8cac9-9f19-4f09-9eb7-71661cf003c0/tool/e2c4d983-f0d7-4b16-b69b-7235434d4adb/jsf/delivery/beginTakingAss… 1/8
5/13/2021 campuslink.admin : HCM21_CPL_JAVA_05 : Tests & Quizzes

B.
"SELECT p.ProductName,DATEPART(mm, com.ComplaintDate) ComplaintMonth,SUM(p.SalePrice) AS
Sales
FROM product p
INNER JOIN complaint com ON p.ProductID = com.ProductID
GROUP BY CUBE;.CustomerName,COUNT(com.ComplaintID) AS complaints
FROM customer c INNER JOIN complaint com ON c.CustomerID = com.CustomerID
GROUP BY c.CustomerName
HAVING COUNT(com.ComplaintID) > 10;
"

C. "SELECT c.CustomerName, AVG(p.SalePrice) AS Sales


FROM product p
INNER JOIN complaint com ON p.ProductID = com.ProductID
INNER JOIN customer c ON com.CustomerID = c.CustomerID
WHERE com.ComplaintDate > '09/01/2011'
GROUP BY c.CustomerName
HAVING AVG(p.SalePrice) >= 500
"

Reset Selection

Question 3 of 20
Sub-queries can be nested in? 5.0 Points

A. INSERT statements only.

B. UPDATE, DELETE, INSERT and SELECT statements.

C. UPDATE statements only.

D. DELETE statements only.

Reset Selection

Question 4 of 20
What type of join is needed when you wish to return rows when there is at least one match in both 5.0 Points
tables?

A. Cross-join

B. Inner join

C. Outer join

D. All of the above.

Reset Selection

https://gst.fsoft.com.vn/portal/site/b0d8cac9-9f19-4f09-9eb7-71661cf003c0/tool/e2c4d983-f0d7-4b16-b69b-7235434d4adb/jsf/delivery/beginTakingAss… 2/8
5/13/2021 campuslink.admin : HCM21_CPL_JAVA_05 : Tests & Quizzes

Question 5 of 20
5.0 Points
How many rows are included in the table gained as as result of execution of the following
statement?
SELECT DISTINCT customer_name, merchandise_name, unit_price
FROM order_table, merchandise_table
WHERE order_table.merchandise_number = merchandise_table.mnrchandise_number

A. 3

B. 2

C. 4

D. 5

Reset Selection

Question 6 of 20
What type of join is needed when you wish to include rows when there is a match between the 5.0 Points
tables?

A. Cross-join

B. Inner join

C. Outer join

D. All of the above

Reset Selection

Question 7 of 20
There should be one condition within the WHERE clause for each pair of tables being joined. 5.0 Points

True
False
Reset Selection

https://gst.fsoft.com.vn/portal/site/b0d8cac9-9f19-4f09-9eb7-71661cf003c0/tool/e2c4d983-f0d7-4b16-b69b-7235434d4adb/jsf/delivery/beginTakingAss… 3/8
5/13/2021 campuslink.admin : HCM21_CPL_JAVA_05 : Tests & Quizzes

Question 8 of 20
The joining technique is useful when data from several relations are to be retrieved and displayed 5.0 Points
and the relationships are not necessarily nested

True
False
Reset Selection

Question 9 of 20
We refer to a join as a self-join when? 5.0 Points

A. we are joining table to itself

B. we are using left and right join together

C. we are joining more than 2 tables

D. We are joining two tables only

Reset Selection

Question 10 of 20
5.0 Points
Which of the following SQL statements can extract the average salary by department from tables A
and B?

A. " SELECT department_code, department_name, AVR(salary) FROM Table_A, Table_B


WHERE Table_A.belonging_code = Table_B.department_code
ORDER BY department_code"

B. " SELECT department_code, department_name, AVR(salary) FROM Table_A, Table_B


ORDER_BY department_code"

C. " SELECT department_code, department_name, AVR(salary) FROM Table_A, Table_B


WHERE Table_A.belonging_code = Table_B.department_code
GROUP BY department_code, department_name"

https://gst.fsoft.com.vn/portal/site/b0d8cac9-9f19-4f09-9eb7-71661cf003c0/tool/e2c4d983-f0d7-4b16-b69b-7235434d4adb/jsf/delivery/beginTakingAss… 4/8
5/13/2021 campuslink.admin : HCM21_CPL_JAVA_05 : Tests & Quizzes

D. " SELECT department_code, department_name, AVR(salary) FROM Table_A, Table_B


WHERE Table_A.belonging_code = Table_B.department_code"

Reset Selection

Question 11 of 20
A UNION query is which of the following? 5.0 Points

A. Combines the output from multiple queries and does not include the same number of columns

B. Combines the output from multiple queries and must include the same number of columns.

C.
Combines the output from no more than two queries and does not include the same number of columns

D. Combines the output from no more than two queries and must include the same number of columns.

Reset Selection

Question 12 of 20
The following SQL is which type of join: 5.0 Points
SELECT CUSTOMER_T.CUSTOMER_ID, ORDER_T.CUSTOMER_ID, NAME, ORDER_ID
FROM CUSTOMER_T, ORDER_T ;

A. Inner Join

B. Self Join

C. Outer Join

D. Cross Join

Reset Selection

Question 13 of 20
Which of the following is one of the basic approaches for joining tables? 5.0 Points

A. Subqueries

B. Union Join

C. Inner/Outer join

D. All of the above

Reset Selection

Question 14 of 20
5.0 Points
https://gst.fsoft.com.vn/portal/site/b0d8cac9-9f19-4f09-9eb7-71661cf003c0/tool/e2c4d983-f0d7-4b16-b69b-7235434d4adb/jsf/delivery/beginTakingAss… 5/8
5/13/2021 campuslink.admin : HCM21_CPL_JAVA_05 : Tests & Quizzes

You have a database that contains two tables named ProductCategory and ProductSubCategory. You need to
write a query that returns a list of product categories that contain more than ten sub-categories. Which query
should you use?

A. SELECT [Name]
FROM ProductSubCategory
WHERE ProductCategoryID IN (SELECT ProductCategoryID
FROM ProductCategory)
GROUP BY [Name]
HAVING COUNT(*) > 10

B. SELECT [Name]
FROM ProductSubCategory
WHERE ProductCategoryID NOT IN (SELECT ProductCategoryID
FROM ProductCategory)
GROUP BY [Name]
HAVING COUNT(*) > 10

C. SELECT [Name]
FROM ProductCategory c
WHERE EXISTS (SELECT ProductCategoryID
FROM ProductSubCategory
WHERE ProductCategoryID = c.ProductCategoryID
GROUP BY ProductCategoryID
HAVING COUNT(*) > 10)

Reset Selection

Question 15 of 20
The IN SQL keyword? 5.0 Points

A. Defines the tables we are selecting or deleting data from.

B. Is used with the DISTINCT SQL keyword only.

C. Determines if a value matches any of the values in a list or a sub-query.

D. Is used with the INSERT SQL keyword only.

Reset Selection

Question 16 of 20
How many tables may be included with a join? 5.0 Points

A. One

B. Two

https://gst.fsoft.com.vn/portal/site/b0d8cac9-9f19-4f09-9eb7-71661cf003c0/tool/e2c4d983-f0d7-4b16-b69b-7235434d4adb/jsf/delivery/beginTakingAss… 6/8
5/13/2021 campuslink.admin : HCM21_CPL_JAVA_05 : Tests & Quizzes

C. Three

D. All of the mentioned options.

Reset Selection

Question 17 of 20
In SQL language, one data manipulation command that combines the records from two tables is 5.0 Points
called

A. PRODUCT

B. SELECT

C. JOIN

D. PROJECT

Reset Selection

Question 18 of 20
A correlated sub-query is where the outer query depends on data from the inner query. 5.0 Points

True
False
Reset Selection

Question 19 of 20
The UNION clause is used to combine the output from multiple queries together into a single result 5.0 Points
table

True
False
Reset Selection

Question 20 of 20
The following SQL is which type of join: 5.0 Points
SELECT CUSTOMER_T.CUSTOMER_ID, ORDER_T.CUSTOMER_ID, NAME, ORDER_ID
FROM CUSTOMER_T, ORDER_T
WHERE CUSTOMER_T.CUSTOMER_ID = ORDER_T.CUSTOMER_ID

A. Inner Join

B. Self Join

C. Outer Join

D. Cross Join

https://gst.fsoft.com.vn/portal/site/b0d8cac9-9f19-4f09-9eb7-71661cf003c0/tool/e2c4d983-f0d7-4b16-b69b-7235434d4adb/jsf/delivery/beginTakingAss… 7/8
5/13/2021 campuslink.admin : HCM21_CPL_JAVA_05 : Tests & Quizzes

Reset Selection

Save Exit Submit for Grading

Gateway
Accessibility Information
The Sakai Project

Powered by Sakai
Copyright 2017 FPT-Software

https://gst.fsoft.com.vn/portal/site/b0d8cac9-9f19-4f09-9eb7-71661cf003c0/tool/e2c4d983-f0d7-4b16-b69b-7235434d4adb/jsf/delivery/beginTakingAss… 8/8

You might also like