Question Bank Oracle
Question Bank Oracle
Question Bank Oracle
Q2
You query the database with this SQL statement:
SELECT bonus
FROM salary
WHERE bonus BETWEEN 1 AND 250
OR (bonus IN(190, 500, 600)
AND bonus BETWEEN 250 AND 500);
100
260
400
600
Q3
Seniority is based on the number of years a student has been enrolled at the university. You
must create a report that displays each student's name, ID number, and the number of
years enrolled. The years enrolled must be rounded to a whole number, based on the
number of months from the date enrolled until today.
A new standard was adopted in your department affecting reports produced by querying
the transaction table. When creating reports, a dash (-) followed by the three characters
'ANI' must be appended to all transaction codes that contain only three characters. Any
leading 'W' in a transaction code must be removed from the resulting data display.
Which SELECT statement will return the same result as the given statement?
SELECT emp_id
FROM emp
UNION
SELECT emp_id
FROM emp_hist;
SELECT e.emp_id
FROM emp e, emp_hist h;
WHERE e.emp_id <> h.emp_id;
SELECT emp_id
FROM emp
MINUS
SELECT emp_id
FROM emp_hist;
SELECT emp_id
FROM emp
INTERSECT
SELECT emp_id
FROM emp_hist;
Q6
You want to display order id numbers, product id numbers, and the quantities ordered for
each of the products ordered with these desired results:
Which statement about using this query as the proposed solution is true?
The results will contain the distinct EMP_ID values return by either query.
Q8
Assume the user enters the following SELECT statement to retrieve data from
the TEACHER table:
SQL> SELECT *
FROM teacher
WHERE INSTR(subject_id, '&1') = 4
AND LOWER(subject_id) LIKE 'HST%';
When prompted for the WHERE clause value, you enter an underscore (_).
It will display information on all teachers whose SUBJECT_ID begins with 'HST_'.
It will return a syntax error because the TO_CHAR function was not used in the WHERE clause.
It will display information on all teachers whose SUBJECT_ID begins with 'HST_', regardless of the
case in which the SUBJECT_ID is stored.
Q9
ID NUMBER PK
SERVICE_DATE DATE
TECHNICIAN_ID NUMBER
DESCRIPTION VARCHAR2(50)
Which SELECT statement could you use to display the number of times each technician
performed a service between January 1, 2008 and June 30, 2008?
SELECT COUNT(*)
FROM service
WHERE service_date BETWEEN '01-JAN-2008' AND '30-JUN-2008'
GROUP BY service_date;
SELECT COUNT(service_date)
FROM service
WHERE service_date BETWEEN '01-JAN-2008' AND '30-JUN-2008'
GROUP BY service_date;
SELECT technician_id, service_date, COUNT(*)
FROM service
WHERE service_date BETWEEN '01-JAN-2008' AND '30-JUN-2008'
ORDER BY technician_id, service_date;
SELECT technician_id, COUNT(technician_id)
FROM service
WHERE service_date BETWEEN '01-JAN-2008' AND '30-JUN-2008'
GROUP BY technician_id;
Q10
You want to query the TEACHER table and display the following results:
Name Subject
------------------------------------- -------------------
Jones, Karen HST_REVOL
Hopewell, Mary Elizabeth HST_RELIG
'14-FEB-2002' + 25
'03-JAN-2000' - 30
'17-JUN-1999' * (480/24)
TO_DATE('01-JAN-2001') - TO_DATE('01-DEC-2000')
Q12
Which set operator would you use to display the employee IDs of employees hired after
January 10, 2007 in the EMP table and employee IDs of employees who have held more
than one position in the EMP_HISTtable, eliminating any duplicate IDs?
UNION
UNION ALL
INTERSECT
MINUS
Use the table aliases instead of the table names in the WHERE clause.
Remove the table alias from the ORDER BY clause and use only the column name.
Q14
Which SELECT statement should you use if you want to display unique combinations of
the POSITION and MANAGER values from the EMPLOYEE table?
Q15
Tsu, Ming
Hann, Jeff
Smith, Ellen
No value is displayed.
ACCOUNT_ID NUMBER(12)
NEW_PURCHASES NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
You must print a report that contains the account number and the current balance for a
particular customer. The current balance consists of the sum of an account's previous
balance, new purchases, and finance charge. You must calculate the finance charge based
on a rate of 1.5 percent of the previous balance. Payments must be deducted from this
amount. The customer's account number is 543842.
Q17.
Examine the structure of the LINE_ITEM table.
You must display the order number, line item number, product identification
number, and quantity of each item where the quantity ranges from 10 through
100. The order numbers must be in the range of 1500 through 1575. The results
must be sorted by order number from lowest to highest, and then further sorted
by quantity from highest to lowest.
Q19. Review the structure and the data contained in the EMPLOYEE_MASTER table.
Employees are given performance reviews once a year and that results in a rating between
1 (lowest) and 5 (highest). This rating and the current salary are stored in
the EMPLOYEE_MASTER table. Proposed new salaries are based upon the current salary
and the performance rating. If an employee received a performance rating of 5, their
proposed new salary would increase the current salary by 5%. Performance ratings of 4
would result in a 3% proposed increase over the current salary, and a rating of 3
would increase the current salary by 2%. Employees with a rating of 2 or 1 would
not receive an increase.
The finance department has been requested to print a report showing each employee_
id, name, current_salary, proposed_salary, job_code, and mgr_id. This report
should NOT include employees who work in sales, nor should it include the CEO due to
privacy concerns. Sales employees can be identified by a job_code of either 25 or 27.
The CEO does not have a manager, so for the purpose of storing data into the table it
appears the CEO?s manager is himself. While all other employees have a mgr_id of
another employee in the company, the CEO has a mgr_id value identical to
his employee_id.
Which one of the following SELECT statements will produce the report as it has been
defined?
ACCOUNT_ID NUMBER(12)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
With the least amount of effort, you want to display all of the rows in the ACCOUNT table.
Which query should you use?
a SELECT *
FROM account;
b SELECT all
FROM account;
c SELECT any
FROM account;
EMPLOYEE
------------------
EMP_ID NUMBER NOT NULL PK
NAME VARCHAR(30) NOT NULL
FNAME VARCHAR(25) NOT NULL
DEPT_NO NUMBER
TITLE VARCHAR2(25)
DEPARTMENT
------------------------
DEPT_ID NUMBER NOT NULL PK
DEPT_NAME VARCHAR2(25)
You need to produce a list of departments, including the department name, which have
more than three administrative assistants.
a SELECT dept_name
FROM employee JOIN department
ON employee.dept_id = department.dept_id
WHERE UPPER(title) = 'ADMINISTRATIVE ASSISTANT'
GROUP BY dept_name
HAVING emp_id > 3;
b SELECT dept_name
FROM employee
GROUP BY dept_no
HAVING LOWER(title) = 'administrative assistant' AND COUNT(*) > 3;
c SELECT dept_name
FROM employee NATURAL JOIN department
WHERE LOWER(title) = 'administrative assistant'
GROUP BY dept_name
HAVING COUNT(emp_id) > 3;
d SELECT dept_name
FROM employee e JOIN department d
ON (e.dept_no = d.dept_id)
WHERE LOWER(title) = 'administrative
assistant'
AND COUNT(*) > 3;
e SELECT d.dept_name
FROM employee e JOIN department d
ON (e.dept_no = d.dept_id)
WHERE LOWER(title) = 'administrative assistant'
GROUP BY dept_name
HAVING COUNT(emp_id) > 3;
f SELECT d.dept_name
FROM e.employee JOIN d.department
ON (e.dept_no = d.dept_id)
WHERE LOWER(title) = 'administrative assistant'
GROUP BY dept_name
HAVING COUNT(emp_id) > 3;
Q23.
Which three functions can be used to manipulate character column values? (Choose three.)
a RPAD
b TRUNC
c ROUND
d INSTR
e CONCAT
Q24. Examine the data in the PRODUCT table.
Q25. Examine the data from the PO_HEADER and PO_DETAIL tables.
You need to produce a report to identify any PO_HEADER rows that have no
matching PO_DETAIL rows and any PO_DETAIL rows that have no
matching PO_HEADER record.
a SELECT product_id
FROM product
WHERE qty_per_unit >= 500
ORDER BY supplier_id, product_id;
b SELECT product_id
FROM product
WHERE qty_per_unit >= 500
SORT BY supplier_id, product_id;
c SELECT product_id
FROM product
WHERE qty_per_unit >= 500
ORDER BY supplier_id, product_id DESC;
d SELECT product_id
FROM product
WHERE qty_per_unit > 500
SORT BY supplier_id, product_id;
Q27. Calculate the value returned by this SELECT statement:
a 2
b -2
c 0
d 13
e -1
Q28. The table called customer contains a column called city, which is defined
as VARCHAR2(15). The application developer believes that a couple of cities actually are
stored in a truncated manner because the name of the city, when written out in English, is
more than 15 characters. Which SELECT statement will find
the customer_name and city where all 15 characters are being used to store the name
of the city?
Which query should you use to display only the full name of each teacher along with the
identification number of the subject each teacher is responsible for teaching?
a SELECT *
FROM teacher;
b SELECT last_name, subject_id
FROM teacher;
c SELECT last_name, first_name, id
FROM teacher;
d SELECT last_name, first_name, subject_id
FROM teacher;