Which two statements are true regarding the count function?
A.
The count function can be used only for CHAR, VARCHAR2, and NUMBER data types.
B.
Count (*) returns the number of rows including duplicate rows and rows containing null
value in any of the columns.
C.
Count (cust_id) returns the number of rows including rows with duplicate customer IDs
and NULL value in the CUST_ID column.
D.
Count (distinct inv_amt) returns the number of rows excluding rows containing duplicates
and NULL values in the INV_AMT column.
E.
A select statement using the COUNT function with a DISTINCT keyword cannot have a
where clause.
Explanation:
Using the COUNT Function
The COUNT function has three formats:
COUNT(*)
COUNT(expr)
COUNT(DISTINCT expr)
COUNT(*) returns the number of rows in a table that satisfy the criteria of the SELECT
statement,
including duplicate rows and rows containing null values in any of the columns. If a WHERE
clause is included in the SELECT statement, COUNT(*) returns the number of rows that
satisfy the condition in the WHERE clause.
In contrast,
COUNT(expr) returns the number of non-null values that are in the column identified by expr.
COUNT(DISTINCT expr) returns the number of unique, non-null values that are in the
column identified by expr.
B, D
Can someone help here to answer these five questions. These are new question came into 1z0-061 exam..Thanks
1. Which statement is true about SQL query processing in an Oracle database instance? (CHOOSE ONE ANSWER).
A: During parsing, a SQL statement containing literals in the WHERE clause that has been executed by any session and which is cached in memory, is always reused for the current execution.
B: During execution, the oracle server may read data from storage if the required data is not already in memory.
C: During row source generation, rows that satisfy the query are retrieved from the database and stored in memory.
D: During optimization, execution plans are formulated based on the statistics gathered by the database instance, and the lowest cost plan is selected for execution.
2. You must display details of all users whose username contains the string ‘ch_’.
Which query generates the required output? (CHOOSE ONE ANSWER).
A: SELECT * FROM users
WHERE user_name LIKE ‘%ch_’;
B: SELECT * FROM users
WHERE user_name LIKE ‘%ch_%’ ESCAPE ‘%’;
C: SELECT * FROM users
WHERE user_name LIKE ‘ch\_%’ ESCAPE ‘_’;
D: SELECT * FROM users
WHERE user_name LIKE ‘%ch\_%’ ESCAPE ‘\’;
3. Examine the structure of the EMPLOYEES table.
NAME TYPE
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8, 2)
COMMISION_PCT NUMBER(2, 2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
You must display the details of employees who have manager with MANAGER_ID 100, who were hired in the past 6 months and who have salaries greater than 10000. (CHOOSE ONE ANSWER).
A: SELECT last_name, hire_date, salary
FROM employees
WHERE salary > 10000
UNION ALL
SELECT last_name, hire_date, salary
FROM employees
WHERE manager_ID = (SELECT employee_id FROM employees WHERE employee_id = 100)
INETRSECT
SELECT last_name, hire_date, salary
FROM employees
WHERE hire_date > SYSDATE – 180;
B: SELECT last_name, hire_date, salary
FROM employees
WHERE manager_id = (SELECT employee_id FROM employees WHERE employee_id = 100)
UNION ALL
(SELECT last_name, hire_date, salary
FROM employees
WHERE hire_date > SYSDATE – 180
INTERSECT
SELECT last_name, hire_date, salary
FROM employees
WHERE salary > 10000);
C: SELECT last_name, hire_date, salary
FROM employees
WHERE manager_id = (SELECT employee_id FROM employees WHERE employee_id = ‘100’)
UNION
SELECT last_name, hire_date, salary
FROM employees
WHERE hire_date > SYSDATE – 180
INTERSECT
SELECT last_name, hire_date, salary
FROM employees
WHERE salary > 10000;
D: (SELECT last_name, hire_date, salary
FROM employees
WHERE salary > 10000
UNION ALL
SELECT last_name, hire_date, salary
FROM employees
WHERE manager_ID = (SELECT employee_id FROM employees WHERE employee_id = 100))
UNION
SELECT last_name, hire_date, salary
FROM employees
WHERE hire_date > SYSDATE – 180;
4. Which two are the minimal requirements for a self join? (CHOOSE TWO ANSWERS).
A: Only equijoin conditions may be used in the query.
B: outer joins must not be used in the query.
C: There must be a condition on which the self join is performed.
D: No other condition except the self-join may be specified.
E: The table used for the self join must have two different alias names in the query.
5. You must write a query that prompts users for column names and conditions every time it is executed.
The user must be prompted only once for the table name
Which statement achieves those objectives?? (CHOOSE ONE ANSWER)
A: SELECT &col1, ‘&col2’
FROM &table
WHERE &&condition = ‘&cond’;
B: SELECT &col1, &col2
FROM “&table”
WHERE &condition = &cond;
C: SELECT &col1, &col2
FROM &&table
WHERE &condition = &cond;
D: SELECT &col1, &col2
FROM &&table
WHERE &condition = &&cond;
have u cleared exam