# Update 1Z0-051 Dumps with VCE and PDF for Free (Question 41 – Question 60)

QUESTION 41
View the Exhibit and examine the structure of CUSTOMERS and GRADES tables. You need to display names and grades of customers who have the highest credit limit. Which two SQL statements would accomplish the task? (Choose two.)

WHERE (SELECT MAX(cust_credit_limit)
FROM customers) BETWEEN startval and endval;
WHERE (SELECT MAX(cust_credit_limit)
FROM customers) BETWEEN startval and endval
AND cust_credit_limit BETWEEN startval AND endval;
WHERE cust_credit_limit = (SELECT MAX(cust_credit_limit)
FROM customers)
AND cust_credit_limit BETWEEN startval AND endval;
WHERE cust_credit_limit IN (SELECT MAX(cust_credit_limit)
FROM customers)
AND MAX(cust_credit_limit) BETWEEN startval AND endval;

QUESTION 42
Examine the structure of the PRODUCTS table.

You want to display the names of the products that have the highest total value for UNIT_PRICE * QTY_IN_HAND. Which SQL statement gives the required output?

A.    SELECT prod_name
FROM products
WHERE (unit_price * qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand) FROM products);
B.    SELECT prod_name
FROM products
WHERE (unit_price * qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand) FROM products
GROUP BY prod_name);
C.    SELECT prod_name
FROM products
GROUP BY prod_name
HAVING MAX(unit_price * qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand) FROM products
GROUP BY prod_name);
D.    SELECT prod_name
FROM products
WHERE (unit_price * qty_in_hand) = (SELECT MAX(SUM(unit_price * qty_in_hand)) FROM products)
GROUP BY prod_name;

QUESTION 43
View the Exhibit and examine the structure of the PRODUCTS table. Evaluate the following query:

What would be the outcome of executing the above SQL statement?

A.    It produces an error.
C.    It shows the names of products whose list price is the second highest in the table.
D.    It shows the names of all products whose list price is less than the maximum list price.

QUESTION 44
View the Exhibit and examine the structure of the PROMOTIONS table. You have to generate a report that displays the promo name and start date for all promos that started after the last promo in the ‘INTERNET’ category. Which query would give you the required output?

A.    SELECT promo_name, promo_begin_date FROM promotions
WHERE promo_begin_date > ALL (SELECT MAX(promo_begin_date) FROM promotions )AND
promo_category = ‘INTERNET’;
B.    SELECT promo_name, promo_begin_date FROM promotions
WHERE promo_begin_date IN (SELECT promo_begin_date
FROM promotions
WHERE promo_category=’INTERNET’);
C.    SELECT promo_name, promo_begin_date FROM promotions
WHERE promo_begin_date > ALL (SELECT promo_begin_date
FROM promotions
WHERE promo_category = ‘INTERNET’);
D.    SELECT promo_name, promo_begin_date FROM promotions
WHERE promo_begin_date > ANY (SELECT promo_begin_date
FROM promotions
WHERE promo_category = ‘INTERNET’);

QUESTION 45
View the Exhibit and examine the structure of the PRODUCTS table. You want to display the category with the maximum number of items. You issue the following query:
SQL>SELECT COUNT(*),prod_category_id
FROM products
GROUP BY prod_category_id
HAVING COUNT(*) = (SELECT MAX(COUNT(*)) FROM products);
What is the outcome?

A.    It executes successfully and gives the correct output.
B.    It executes successfully but does not give the correct output.
C.    It generates an error because the subquery does not have a GROUP BY clause.
D.    It generates an error because = is not valid and should be replaced by the IN operator.

QUESTION 46
View the Exhibit and examine the structure of the CUSTOMERS table. You issue the following SQL statement on the CUSTOMERS table to display the customers who are in the same country as customers with the last name ‘KING’ and whose credit limit is less than the maximum credit limit in countries that have customers with the last name ‘KING’:

Which statement is true regarding the outcome of the above query?

A.    It executes and shows the required result.
B.    It produces an error and the < operator should be replaced by < ALL to get the required output.
C.    It produces an error and the < operator should be replaced by < ANY to get the required output.
D.    It produces an error and the IN operator should be replaced by = in the WHERE clause of the main query to get the required output.

QUESTION 47
Evaluate the following SQL statement:
SQL> SELECT cust_id, cust_last_name
FROM customers
WHERE cust_credit_limit IN
(select cust_credit_limit
FROM customers
WHERE cust_city =’Singapore’);
Which statement is true regarding the above query if one of the values generated by the subquery is NULL?

A.    It produces an error.
B.    It executes but returns no rows.
C.    It generates output for NULL as well as the other values produced by the subquery.
D.    It ignores the NULL value and generates output for the other values produced by the subquery.

QUESTION 48
View the Exhibit and examine the structure of the PROMOTIONS table.
Evaluate the following SQL statement:
SQL>SELECT promo_name,CASE
WHEN promo_cost >=(SELECT AVG(promo_cost)
FROM promotions
WHERE promo_category=’TV’)
then ‘HIGH’
else ‘LOW’
END COST_REMARK
FROM promotions;
Which statement is true regarding the outcome of the above query?

A.    It shows COST_REMARK for all the promos in the table.
B.    It produces an error because the subquery gives an error.
C.    It shows COST_REMARK for all the promos in the promo category ‘TV’.
D.    It produces an error because subqueries cannot be used with the CASE expression.

QUESTION 49
View the Exhibit and examine the structure of the PRODUCTS tables. You want to generate a report that displays the average list price of product categories where the average list price is less than half the maximum in each category. Which query would give the correct output?

A.    SELECT prod_category,avg(prod_list_price)
FROM products
GROUP BY prod_category
HAVING avg(prod_list_price) < ALL
(SELECT max(prod_list_price)/2
FROM products
GROUP BY prod_category);
B.    SELECT prod_category,avg(prod_list_price)
FROM products
GROUP BY prod_category
HAVING avg(prod_list_price) > ANY
(SELECT max(prod_list_price)/2
FROM products
GROUP BY prod_category);
C.    SELECT prod_category,avg(prod_list_price)
FROM products
HAVING avg(prod_list_price) < ALL
(SELECT max(prod_list_price)/2
FROM products
GROUP BY prod_category);
D.    SELECT prod_category,avg(prod_list_price)
FROM products
GROUP BY prod_category
HAVING avg(prod_list_price) > ANY
(SELECT max(prod_list_price)/2
FROM products);

Explanation:
Using the ANY Operator in Multiple-Row Subqueries
The ANY operator (and its synonym, the SOME operator) compares a value to each value returned by a subquery.
<ANY means less than the maximum.
>ANY means more than the minimum.
=ANY is equivalent to IN
Using the ALL Operator in Multiple-Row Subqueries
The ALL operator compares a value to every value returned by a subquery.
>ALL means more than the maximum and
<ALL means less than the minimum.
The NOT operator can be used with IN, ANY, and ALL operators.

QUESTION 50
View the Exhibits and examine the structures of the COSTS and PROMOTIONS tables. Evaluate the following SQL statement:
SQL> SELECT prod_id FROM costs
WHERE promo_id IN (SELECT promo_id FROM promotions
WHERE promo_cost < ALL
(SELECT MAX(promo_cost) FROM promotions
GROUP BY (promo_end_date-promo_begin_date)));
What would be the outcome of the above SQL statement?

A.    It displays prod IDs in the promo with the lowest cost.
B.    It displays prod IDs in the promos with the lowest cost in the same time interval.
C.    It displays prod IDs in the promos with the highest cost in the same time interval.
D.    It displays prod IDs in the promos with cost less than the highest cost in the same time interval.

QUESTION 51
View the Exhibit and examine the data in the PROMOTIONS table. You need to display all promo categories that do not have ‘discount’ in their subcategory. Which two SQL statements give the required result? (Choose two.)

A.    SELECT promo_category
FROM promotions
MINUS
SELECT promo_category
FROM promotions
WHERE promo_subcategory = ‘discount’;
B.    SELECT promo_category
FROM promotions
INTERSECT
SELECT promo_category
FROM promotions
WHERE promo_subcategory = ‘discount’;
C.    SELECT promo_category
FROM promotions
MINUS
SELECT promo_category
FROM promotions
WHERE promo_subcategory <> ‘discount’;
D.    SELECT promo_category
FROM promotions
INTERSECT
SELECT promo_category
FROM promotions
WHERE promo_subcategory <> ‘discount’;

QUESTION 52
View the Exhibit and examine the structure of the CUSTOMERS and CUST_HISTORY tables. The CUSTOMERS table contains the current location of all currently active customers. The CUST_HISTORY table stores historical details relating to any changes in the location of all current as well as previous customers who are no longer active with the company. You need to find those customers who have never changed their address. Which SET operator would you use to get the required output?

A.    MINUS
B.    UNION
C.    INTERSECT
D.    UNION ALL

QUESTION 53
Which statement is true regarding the UNION operator?

A.    The number of columns selected in all SELECT statements need to be the same
B.    Names of all columns must be identical across all SELECT statements
C.    By default, the output is not sorted
D.    NULL values are not ignored during duplicate checking

Explanation:
The SQL UNION query allows you to combine the result sets of two or more SQL SELECT statements. It removes duplicate rows between the various SELECT statements. Each SQL SELECT statement within the UNION query must have the same number of fields in the result sets with similar data types.

QUESTION 54
View the Exhibits and examine the structures of the PRODUCTS and SALES tables. Which two SQL statements would give the same output? (Choose two.)

A.    SELECT prod_id FROM products
INTERSECT
SELECT prod_id FROM sales;
B.    SELECT prod_id FROM products
MINUS
SELECT prod_id FROM sales;
C.    SELECT DISTINCT p.prod_id
FROM products p JOIN sales s
ON p.prod_id=s.prod_id;
D.    SELECT DISTINCT p.prod_id
FROM products p JOIN sales s
ON p.prod_id <> s.prod_id;

QUESTION 55
View the Exhibit and evaluate structures of the SALES, PRODUCTS, and COSTS tables.

Evaluate the following SQL statement:

Which statement is true regarding the above compound query?

A.    It produces an error.
B.    It shows products that were sold and have a cost recorded.
C.    It shows products that were sold but have no cost recorded.
D.    It shows products that have a cost recorded irrespective of sales.

QUESTION 56
Evaluate the following SQL statement:
SQL> SELECT promo_id, promo_category
FROM promotions
WHERE promo_category = ‘Internet’ ORDER BY 2 DESC
UNION
SELECT promo_id, promo_category
FROM promotions
WHERE promo_category = ‘TV’
UNION
SELECT promo_id, promo_category
FROM promotions
Which statement is true regarding the outcome of the above query?

A.    It executes successfully and displays rows in the descending order of PROMO_CATEGORY.
B.    It produces an error because positional notation cannot be used in the ORDER BY clause with SET operators.
C.    It executes successfully but ignores the ORDER BY clause because it is not located at the end of the compound statement.
D.    It produces an error because the ORDER BY clause should appear only at the end of a compound query-that is, with the last SELECT statement.

Explanation:
Using the ORDER BY Clause in Set Operations
The ORDER BY clause can appear only once at the end of the compound query. Component queries cannot have individual ORDER BY clauses. The ORDER BY clause recognizes only the columns of the first SELECT query.
By default, the first column of the first SELECT query is used to sort the output in an ascending order.

QUESTION 57
Evaluate the following SQL statement:
SQL> SELECT cust_id, cust_last_name “Last Name”
FROM customers
WHERE country_id = 10
UNION
SELECT cust_id CUST_NO, cust_last_name
FROM customers
WHERE country_id = 30;
Which ORDER BY clauses are valid for the above query? (Choose all that apply.)

A.    ORDER BY 2,1
B.    ORDER BY CUST_NO
C.    ORDER BY 2,cust_id
D.    ORDER BY “CUST_NO”
E.    ORDER BY “Last Name”

Explanation:
Using the ORDER BY Clause in Set Operations
– The ORDER BY clause can appear only once at the end of the compound query.
– Component queries cannot have individual ORDER BY clauses.
– The ORDER BY clause recognizes only the columns of the first SELECT query.
– By default, the first column of the first SELECT query is used to sort the output in an ascending order.

QUESTION 58
View the Exhibit and examine the structure of the ORDERS and CUSTOMERS tables. Evaluate the following SQL command:
SQL> SELECT o.order_id, c.cust_name, o.order_total, c.credit_limit
FROM orders o JOIN customers c
USING (customer_id)
WHERE o.order_total > c.credit_limit
FOR UPDATE
ORDER BY o.order_id;
Which two statements are true regarding the outcome of the above query? (Choose two.)

A.    It locks all the rows that satisfy the condition in the statement.
B.    It locks only the columns that satisfy the condition in both the tables.
C.    The locks are released only when a COMMIT or ROLLBACK is issued.
D.    The locks are released after a DML statement is executed on the locked rows.

Explanation:
FOR UPDATE Clause in a SELECT Statement
Locks the rows in the EMPLOYEES table where job_id is SA_REP.
Lock is released only when you issue a ROLLBACK or a COMMIT.
If the SELECT statement attempts to lock a row that is locked by another user, the database waits until the row is available, and then returns the results of the SELECTstatement
SELECT employee_id, salary, commission_pct, job_id
FROM employees
WHERE job_id = ‘SA_REP’
FOR UPDATE
ORDER BY employee_id;

QUESTION 59
Which statements are true regarding the FOR UPDATE clause in a SELECT statement? (Choose all that apply.)

A.    It locks only the columns specified in the SELECT list.
B.    It locks the rows that satisfy the condition in the SELECT statement.
C.    It can be used only in SELECT statements that are based on a single table.
D.    It can be used in SELECT statements that are based on a single or multiple tables.
E.    After it is enforced by a SELECT statement, no other query can access the same rows until a COMMIT or ROLLBACK is issued.

QUESTION 60
View the Exhibit and examine the structure of the CUSTOMERS table. NEW_CUSTOMERS is a new table with the columns CUST_ID, CUST_NAME and CUST_CITY that have the same data types and size as the corresponding columns in the CUSTOMERS table. Evaluate the following INSERT statement:

The INSERT statement fails when executed. What could be the reason?

A.    The VALUES clause cannot be used in an INSERT with a subquery.
B.    Column names in the NEW_CUSTOMERS and CUSTOMERS tables do not match.
C.    The WHERE clause cannot be used in a subquery embedded in an INSERT statement.
D.    The total number of columns in the NEW_CUSTOMERS table does not match the total number of columns in the CUSTOMERS table.