1Z0-051 | how many questions of 1Z0-051 vce?


Q71. - (Topic 1) 

See the structure of the PROGRAMS table: 

Which two SQL statements would execute successfully? (Choose two.) 

A. SELECT NVL(ADD_MONTHS(END_DATE,1),SYSDATE) FROM programs; 

B. SELECT TO_DATE(NVL(SYSDATE-END_DATE,SYSDATE)) FROM programs; 

C. SELECT NVL(MONTHS_BETWEEN(start_date,end_date),'Ongoing') FROM programs; 

D. SELECT NVL(TO_CHAR(MONTHS_BETWEEN(start_date,end_date)),'Ongoing') FROM programs; 

Answer: A,D 

Explanation: 

NVL Function 

Converts a null value to an actual value: 

Data types that can be used are date, character, and number. 

Data types must match: 

– 

NVL(commission_pct,0) 

– 

NVL(hire_date,'01-JAN-97') 

– 

NVL(job_id,'No Job Yet') 

MONTHS_BETWEEN(date1, date2): Finds the number of months between date1 and date2 The result can be positive or negative. If date1 is later than date2, the result is positive; if date1 is earlier than date2, the result is negative. The noninteger part of the result represents a portion of the month. MONTHS_BETWEEN returns a numeric value. - answer C NVL has different datatypes -numeric and strings, which is not possible! 

The data types of the original and if null parameters must always be compatible. They must either be of the same type, or it must be possible to implicitly convert if null to the type of the original parameter. The NVL function returns a value with the same data type as the original parameter. 

Q72. - (Topic 1) 

You need to calculate the number of days from 1st Jan 2007 till date: 

Dates are stored in the default format of dd-mm-rr. 

Which two SQL statements would give the required output? (Choose two.) 

A. SELECT SYSDATE - TO_DATE('01/JANUARY/2007') FROM DUAL; 

B. SELECT TO_DATE(SYSDATE,'DD/MONTH/YYYY')-'01/JANUARY/2007' FROM DUAL; 

C. SELECT SYSDATE - TO_DATE('01-JANUARY-2007') FROM DUAL 

D. SELECT SYSDATE - '01-JAN-2007' FROM DUAL 

E. SELECT TO_CHAR(SYSDATE,'DD-MON-YYYY')-'01-JAN-2007' FROM DUAL; 

Answer: A,C 

Q73. - (Topic 2) 

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_datepromo_ 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. 

Answer:

Q74. - (Topic 2) 

Which two statements are true regarding the DELETE and TRUNCATE commands? (Choose two.) 

A. DELETE can be used to remove only rows from only one table at a time. 

B. DELETE can be used to remove only rows from multiple tables at a time. 

C. DELETE can be used only on a table that is a parent of a referential integrity constraint. 

D. DELETE can be used to remove data from specific columns as well as complete rows. 

E. DELETE and TRUNCATE can be used on a table that is a parent of a referential integrity constraint having ON DELETE rule. 

Answer: A,E 

Explanation: 

Transactions, consisting of INSERT, UPDATE, and DELETE (or even MERGE) commands can be made permanent (with a COMMIT) or reversed (with a ROLLBACK). A TRUNCATE command, like any other DDL command, is immediately permanent: it can never be reversed. The Transaction Control Statements A transaction begins implicitly with the first DML statement. There is no command to explicitly start a transaction. The transaction continues through all subsequent DML statements issued by the session. These statements can be against any number of tables: a transaction is not restricted to one table. It terminates (barring any of the events listed in the previous section) when the session issues a COMMIT or ROLLBACK command. The SAVEPOINT command can be used to set markers that will stage the action of a ROLLBACK, but the same transaction remains in progress irrespective of the use of SAVEPOINT Explicit Transaction Control Statements You can control the logic of transactions by using the COMMIT, SAVEPOINT, and ROLLBACK statements. Note: You cannot COMMIT to a SAVEPOINT. SAVEPOINT is not ANSI-standard SQL. 

untitled 

Q75. - (Topic 2) 

View the Exhibit and examine the structure of the SALES and PRODUCTS tables. 

In the SALES table, PROD_ID is the foreign key referencing PROD_ID in the PRODUCTS table. You want to list each product ID and the number of times it has been sold. 

Evaluate the following query: 

SQL>SELECT p.prod_id, COUNT(s.prod_id) 

FROM products p _____________ sales s 

ON p.prod_id = s.prod_id 

GROUP BY p.prod_id; 

Which two JOIN options can be used in the blank in the above query to get the required output? (Choose two.) 

A. JOIN 

B. FULL OUTER JOIN 

C. LEFT OUTER JOIN 

D. RIGHT OUTER JOIN 

Answer: B,C 

Q76. - (Topic 1) 

Evaluate the following two queries: Exhibit: 

Exhibit: 

Which statement is true regarding the above two queries? 

A. Performance would improve in query 2 only if there are null values in the CUST_CREDIT_LIMIT column 

B. Performance would degrade in query 2 

C. There would be no change in performance 

D. Performance would improve in query 2 

Answer:

Explanation: 

Note: The IN operator is internally evaluated by the Oracle server as a set of OR conditions, such as a=value1 or a=value2 or a=value3. Therefore, using the IN operator 

has no performance benefits and is used only for logical simplicity. 

Q77. - (Topic 1) 

View the Exhibit and examine the structure of the SALES table. 

The following query is written to retrieve all those product IDs from the SALES table that have more than 55000 sold and have been ordered more than 10 times. 

Which statement is true regarding this SQL statement? 

A. It executes successfully and generates the required result. 

B. It produces an error because COUNT(*) should be specified in the SELECT clause also. 

C. It produces an error because COUNT(*) should be only in the HAVING clause and not in the WHERE clause. 

D. It executes successfully but produces no result because COUNT(prod_id) should be used instead of COUNT(*). 

Answer:

Explanation: 

Restricting Group Results with the HAVING Clause 

You use the HAVING clause to specify the groups that are to be displayed, thus further 

restricting the groups on the basis of aggregate information. 

In the syntax, group_condition restricts the groups of rows returned to those groups for 

which the specified condition is true. 

The Oracle server performs the following steps when you use the HAVING clause: 

1. 

Rows are grouped. 

2. 

The group function is applied to the group. 

3. 

The groups that match the criteria in the HAVING clause are displayed. 

The HAVING clause can precede the GROUP BY clause, but it is recommended that you 

place the GROUP BY clause first because it is more logical. Groups are formed and group 

functions are calculated before the HAVING clause is applied to the groups in the SELECT 

list. 

Note: The WHERE clause restricts rows, whereas the HAVING clause restricts groups. 

Q78. - (Topic 1) 

Which two statements are true regarding sub queries? (Choose two.) 

A. A sub query can retrieve zero or more rows. 

B. Only two sub queries can be placed at one level. 

C. A sub query can be used only in SQL query statements. 

D. A sub query can appeal* on either side of a comparison operator. 

E. There is no limit on the number of sub query levels in the WHERE clause of a SELECT statement. 

Answer: A,D 

Q79. - (Topic 1) 

Which three are true? (Choose three.) 

A. A MERGE statement is used to merge the data of one table with data from another. 

B. A MERGE statement replaces the data of one table with that of another. 

C. A MERGE statement can be used to insert new rows into a table. 

D. A MERGE statement can be used to update existing rows in a table. 

Answer: A,C,D 

Explanation: The MERGE Statement allows you to conditionally insert or update data in a table. If the rows are present in the target table which match the join condition, they are updated if the rows are not present they are inserted into the target table 

Q80. - (Topic 2) 

View the Exhibit and examine the structure of the PRODUCTS table. 

Which two tasks would require subqueries? (Choose two.) 

A. Display the minimum list price for each product status. 

B. Display all suppliers whose list price is less than 1000. 

C. Display the number of products whose list price is more than the average list price. 

D. Display the total number of products supplied by supplier 102 and have product status as 'obsolete'. 

E. Display all products whose minimum list price is more than the average list price of products and have the status 'orderable'. 

Answer: C,E