DATABASE-BY-KUYA-NR New
DATABASE-BY-KUYA-NR New
DATABASE-BY-KUYA-NR New
department_name = 'Finance'
ORDER BY "ANNUAL SALARY" DESC
c. SELECT E.employee_id, E.last_name,
E.first_name, D.department_name, E.salary*12 AS
"ANNUAL SALARY", D.location_id
Flag question
FROM employees E
Question text JOIN jobs J ON E.job_id = J.job_id
JOIN departments D ON E.department_id =
In creating Joins,the NATURALJOIN and USING D.department_id
clauses are____________ WHERE D.location_id = 1700 AND
Select one: D.department_name = 'Finance'
ORDER BY "ANNUAL SALARY" DESC
a. Mutually Inclusive
d. SELECT E.employee_id, E.last_name,
b. Limited to 2 relational tables E.first_name, D.department_name, E.salary*12 AS
"ANNUAL SALARY", D.location_id
c. Opposite FROM employees E
d. Mutually Exclusive OUTER JOIN jobs J ON E.job_id = J.job_id
OUTER JOIN departments D ON E.department_id =
Question 24 D.department_id
Complete WHERE D.location_id = 1700 AND
Mark 4.00 out of 4.00 D.department_name = 'Finance'
ORDER BY "ANNUAL SALARY" DESC
Flag question
PROG-113A-LAB-1812S / (47/50)► Week
Question text 10: Quarterly Examination / ► First Quarter
Display employee id, lastname, firstname, department Exam
name, annual salary, location id of employees whose
location id is 1700 and working in Finance Question 1
Department. Label the annual salary to ANNUAL Answer saved
Marked out of 1.00
SALARY.
Sort the output in from highest to lowest salary. (4
POINTS)
Select one:
a. SELECT E.employee_id, E.last_name, Remove flag
E.first_name, D.department_name, E.salary*12 AS
"ANNUAL SALARY", D.location_id Question text
FROM employees E
NATURAL JOIN jobs J ON E.job_id = J.job_id You can relate data to multiple tables using a foreign
NATURAL JOIN departments D ON E.department_id key.
= D.department_id Select one:
ORDER BY "ANNUAL SALARY" DESC
WHERE D.location_id = 1700 AND True
D.department_name = 'Finance'
False
b. SELECT E.employee_id, E.last_name,
E.first_name, D.department_name, E.salary*12 AS Question 2
"ANNUAL SALARY", D.location_id Answer saved
Marked out of 1.00
FROM employees E
JOIN jobs J ON E.job_id = J.job_id
JOINemployees E ON E.department_id =
D.department_id
WHERE D.location_id = 1700 AND
Remove flag Flag question
Flag question
Flag question Question text
Question text
You want to display the employee’s last name
INSERT, DELETE, UPDATE are ________________ whose salary is below 10,000 and whose lastname
commands starts with letter K.
Select one: Which SQL statement give the required output
format of the salary?
a. DCL
Select one:
b. DML
a. SELECT last_name, TO_CHAR(salary,
c. DDL '$999,999.99') AS "MONTHLY SALARY" FROM
d. All of the choices employees WHERE salary < 10000WHERE
last_name LIKE ‘K%’
Question 4
Answer saved
b. SELECT last_name, TO_NUMBER(salary,
Marked out of 1.00 '$999,999.99') AS "MONTHLY SALARY" FROM
employees WHERE salary < 10,000WHERE
last_name = ‘K%’
Question 8
c. SELECT last_name, TO_INTEGER(salary, Answer saved
$999,999.99) AS "MONTHLY SALARY" FROM Marked out of 1.00
employees WHERE salary < 10000 WHERE
last_name IN 'K%'
d. SELECT last_name, TO_INT(salary,
'$999,999.99') AS "MONTHLY SALARY" FROM
employees WHERE salary < 10,000 WHERE
last_name STARTS 'K%' Remove flag
Question text
Question 6
Answer saved You what to generate the average salary of all
Marked out of 1.00 employees whose job function is FI_ACCOUNT.
Which of the following SQL command will produce the
output.
Select one:
Remove flag
a. SELECT AVG(salary) FROM employees
WHERE job_id = 'FI_ACCOUNT';
Question text
b. SELECT AVE(salary) FROM employees
Which of the following is the correct report that will WHERE job_id = 'FI_ACCOUNT';
display the CLASS from table PARTS.
c. SELECT AVERAGE(salary) FROM employees
Select one: WHERE job_id = 'FI_ACCOUNT';
a. SELECT * CLASS FROM PARTS; d. SELECT COUNT AVG(salary) FROM
employees WHERE job_id = 'FI_ACCOUNT';
b. SELECT CLASS AS CLASS FROM PARTS;
Question 9
c. SELECT 'CLASS' FROM PARTS; Answer saved
Marked out of 1.00
d. SELECT CLASS FROM PARTS;
Question 7
Answer saved
Marked out of 1.00
Remove flag
Question text
Evaluate the following SQL command
Remove flag SELECT employee_id, min_salary, max_salary
Question text FROM employees, departments WHERE
salary>= 10000 && salary <= 20000
Evaluate the following SQL command
SELECT employee_id, salary, department_id FROM Select one:
employees WHERE department_id IN (60,70) a. The SQL will produce Cartesian Product
Select one: b. The SQL will display the employee id,
a. The SQL command will display employees with department id and the minimum and maximum salary
department id 60 or 70. whose salary is between 10000 and 20000.
b. The SQL command will give an incorrect c. The SQL command will give an incorrect
output. output.
c. The SQL command will produce an error. d. The SQL command will produce an error.
Flag question
Flag question
Question text
Question text
You want to display the employee's last name whose
salary is below 10,000 and whose lastname starts What is the SQL command to display the date of the
with letter D. first employee that was hired?
Which SQL statement give the required output format
Select one:
of the salary?
a. SELECT FIRST(hire_date) FROM employees;
Select one:
b. SELECT hire_date FROM employees WHERE
a. SELECT last_name, TO_INTEGER(salary,
TO_CHAR(hire_date) = ‘FIRST’;
$999,999.99) AS "MONTHLY SALARY" FROM
employees WHERE salary < 10000 WHERE c. SELECT MIN(hire_date) FROM employees;
last_name IN 'D%'
d. SELECT hire_date FROM employees WHERE
b. SELECT last_name, TO_INT(salary, FIRST(hire_date );
'$999,999.99') AS "MONTHLY SALARY" FROM
employees WHERE salary < 10,000 WHERE Question 13
last_name STARTS 'D%' Answer saved
Marked out of 1.00
c. SELECT last_name, TO_CHAR(salary,
'$999,999.99') AS "MONTHLY SALARY" FROM
employees WHERE salary < 10000 WHERE
last_name LIKE 'D%'
d. SELECT last_name, TO_NUMBER(salary,
Flag question
'$999,999.99') AS "MONTHLY SALARY" FROM
employees WHERE salary < 10,000 WHERE Question text
last_name = ‘D%’
You want to display the employee id and the year
Question 11 when an employee was hired.
Answer saved Which SQL statement give the required output?
Marked out of 1.00
Select one:
a. SELECT employee_id,
YEAR(hire_date,'YYYY') FROM employees;
b. SELECT employee_id, YEAR(hire_date')
Flag question FROM employees;
Question text c. SELECT employee_id,
TO_YEAR(hire_date,'YYYY') FROM employees;
Which of the following will is the correct command to
create a role. d. SELECT employee_id,
TO_CHAR(hire_date,'YYYY') FROM employees;
Select one:
a. CREATE ROLE gen_manager Question 14
Answer saved
b. None of the choices Marked out of 1.00
Question 12
Answer saved Remove flag
Question text Question text
Evaluate the following SQL command TRUE OR FALSE.
SELECT employee_id, hire_date, department_name A FOREIGN KEY is a field in one table that refers to
FROM employees, departments the PRIMARY KEY in another table.
WHERE departments.department_id =
employees.department_id Select one:
Flag question
Question text
d. SELECT COUNT AVG(salary) FROM
employees WHERE job_id = 'IT_PROG'; Display all the records in the employee table. Arrange
the output in by lastname from A-Z order.
Question 19
Answer saved Select one:
Marked out of 1.00
a. SELECT * FROM employees SORT BY
lastname
b. SELECT * FROM employees ORDER BY
lastname AZ
Flag question c. SELECT * FROM employees ORDER BY
lastname
Question text
d. SELECT * FROM employees SORT BY
A _______________ consists of a collection of DML lastname ascending
statements that form a logical unit of work.
Question 22
Select one:
Answer saved
Marked out of 1.00
a. All of the choices
b. Transaction
c. SQL command
d. Database
Flag question
Question 20
Question text
Answer saved
Marked out of 1.00
Austin David was transferred to Purchasing
Department. You are assigned to update the
database.
Which of the following SQL command will satisfy the
requirements?
Remove flag Select one:
Question text a. UPDATE first_name = ‘David’ AND last_name
= ‘Austin’ FROM employees SET department_id = 30
Which of the following SELECT statement is the
correct PL/SQL that will display all rows and b. UPDATE employees SET department_id = 30
columns? WHERE first_name = ‘David’ AND last_name =
‘Austin’
Select one:
c. UPDATE department_id = 30 WHERE
a. SELECT TABLE PARTS; first_name = ‘David’ AND last_name = ‘Austin’
b. SELECT FROM TABLE PARTS; d. UPDATE employees WHERE department_id =
c. SELECT * FROM PARTS; 30 SET first_name = ‘David’ AND last_name =
‘Austin’
d. SELECT ALL FROM PARTS;
Question 23
Question 21 Answer saved
Answer saved Marked out of 1.00
Marked out of 1.00
Flag question
Remove flag
Question text
The General Manager request to the Database
Administrator to generate the total number of parts
and total outstanding balance on hand of every class
in warehouse number 1&2.
Which of the following SQL command will generate
the required output. Flag question
Question 24
Answer saved
Marked out of 1.00
Remove flag
Question text
Each row of data in a table can be uniquely identified
by a
Flag question Select one:
Question text a. foreign key
John want to know how many employees receiving b. primary key
salary below 10,000.
What SQL command he need to run? c. local key
Select one: d. relational key
a. SELECT COUNT(salary) FROM employees e. index key
WHERE salary < 10,000;
Question 27
b. SELECT COUNT(*) FROM employees Answer saved
WHERE salary < 10000; Marked out of 1.00
Question 30
Answer saved
Marked out of 1.00
Remove flag
Question text
Display all location id between 1000 to 2000.
Flag question
Select one:
Question text
a. DISPLAY location_id FROM departments
WHERE location_id LING 1000 UP TO 2000 There was 10% price increase in the all the parts in
warehouse number 3. The Store Manager asked the
b. SELECT location_id FROM departments Database Administrator to generate a report showing
WHERE location_id IN 1000 AND 2000 the part number, the old and new price.
c. DISPLAY location_id FROM departments Which of the following SQL statement would satisfy
WHERE location_id BETWEEN 1000 TO 2000 the requirement of the Store Manager.
Flag question
Question text
Flag question
Aldrin wants to know the highest salary in every
department. Which of the following SQL command will Question text
display the required output? Which of the following describes the command
Select one: below?
SELECT * FROM employees WHERE department =
a. SELECT department_id, HIGH(salary) FROM 60 FOR UPDATE
employees GROUP BY department_id AND salary;
Select one:
b. SELECT department_id, HIGHEST(salary)
FROM employees GROUP BY salary; a. Locks the rows in the EMPLOYEES table with
department id is 60.
c. SELECT department_id, MAX(salary) FROM
employees GROUP BY department_id b. Unlock all records with department id = 60
Remove flag
Question text
Flag question
You want to display all the employee id and the month
an employee was hired. Question text
Which SQL statement give the required output? Display the employee id, number of years and the
Select one: hiring date of every employee in the company.
Question 40
Answer saved
Marked out of 1.00
Remove flag
Question text
Flag question
Display the first 5 letter in the surname of all the
employees whose firstname starts with letter 'N'
Question text
Select one:
The DBA will create a new user name sales.
Which of the following SQL command will perform the a. SELECT SUBSTR(last_name,1,5), first_name
creation? FROM employees WHERE SUBSTR(first_name,1,1)
IN 'N'
Select one:
b. SELECT SUBSTR(last_name,1,5), first_name
a. CREATE USER FR0M DB_USER SET FROM employees WHERE SUBSTR(first_name,1,1)
user=’sales’ password=NULL = 'N'
b. None of the choices c. SELECT SUBSTR(surname,1,5), first_name
FROM employees WHERE first_name = 'N'
c. CREATE USERNAME sales SET PASSWORD
default d. SELECT SUBSTR(surname,1,5), first_name
FROM employees WHERE SUBSTR(first_name,1,1)
d. CREATE sales ACCESS 1234 IN 'N'
e. CREATE USER sales IDENTIFIED BY 1234 e. SELECT SUBSTR(last_name,1,5), first_name
FROM employees WHERE first_name IN 'N'
Question 41
Answer saved
Question 43
Marked out of 1.00
Answer saved
Marked out of 1.00
Flag question
Which of the following SQL command will display the Question text
summary table showing the total quantity on hand per Display the employee id, salary, number of years and
class. the hiring date of every employee in the company.
Select one: Select one:
a. SELECT class, TOTAL(onhand) AS "QTY ON a. SELECT employee_id,salary, hire_date,
HAND" FROM parts GROUP BY class, onhand hire_date- SYSDATE /365 FROM employees;
b. SELECT class, onhand AS "QTY ON HAND" b. SELECT employee_id, salary, hire_date,
FROM parts GROUP BY sum(onhand) hire_date /365 FROM employees;
job_id FROM employees WHERE job_id NOT =
c. SELECT employee_id, salary, hire_date, 'AD_VP';
ROUND((SYSDATE - hire_date) /365,0) FROM
employees; Question 46
Answer saved
Question 44 Marked out of 1.00
Answer saved
Marked out of 1.00
Remove flag
Display the first 5 letter in the surname of all the Question text
employees whose firstname starts with letter 'N'
Evaluate the following SQL command
Select one: SELECT employee_id, salary, department_id FROM
a. SELECT SUBSTR(last_name,1,5), first_name FROM employees WHERE department_id IN (60,70)
employees WHERE first_name IN 'N'
Select one:
b. SELECT SUBSTR(last_name,1,5), first_name FROM
a. The SQL command will produce an error.
employees WHERE SUBSTR(first_name,1,1) = 'N'
b. The SQL command will display employees with
c. SELECT SUBSTR(surname,1,5), first_name FROM
department id 60 and 70.
employees WHERE SUBSTR(first_name,1,1) IN 'N'
c. The SQL command will give an incorrect output.
d. SELECT SUBSTR(surname,1,5), first_name FROM
d. The SQL command will display employees with
employees WHERE first_name = 'N'
department id 60 or 70.
e. SELECT SUBSTR(last_name,1,5), first_name FROM
employees WHERE SUBSTR(first_name,1,1) IN 'N' Question 13
Complete
Question 10 Mark 2.00 out of 2.00
Complete Flag question
Mark 2.00 out of 2.00
Flag question Question text
Question text You want to display the employee's last name and
date hired in year 2000 to2006 whose salary is above
Austin David was transferred to Purchasing
5000. Which SQL statement give the required output?
Department. You are assigned to update the
database. Select one:
Which of the following SQL command will satisfy the a. SELECT last_name, hire_date FROM employees
requirements? WHERE hire_date>=
TO_DATE('01-Jan-2006', 'DD-Mon-RR') AND
Select one:
hire_date<= TO_DATE('31-Dec-2006', 'DD-Mon-RR')
a. UPDATE first_name = ‘David’ AND last_name =
AND salary > 5000;
‘Austin’ FROM employees SET department_id = 30
b. SELECT last_name, hire_date FROM employees
b. UPDATE department_id = 30 WHERE first_name =
WHERE hire_date>=
‘David’ AND last_name = ‘Austin’
TO_DATE('Jan-2000', 'Month-YYYY') AND
c. UPDATE employees WHERE department_id = 30 SET
hire_date<= TO_DATE('Dec-2006', 'Month-‘YYYY')
first_name = ‘David’ AND last_name = ‘Austin’
AND salary > 5,000;
d. UPDATE employees SET department_id = 30 WHERE
c. SELECT last_name, hire_date FROM employees
first_name = ‘David’ AND last_name = ‘Austin’
WHERE hire_date>=
Question 11
TO_DATE('01-Jan-2000', 'DD-Mon-YYYYY') AND
Complete hire_date<= TO_DATE('31-Dec-2006', 'DD-Mon-
Mark 2.00 out of 2.00 YYYY') AND salary ABOVE 5000;
Flag question d. SELECT last_name, hire_date FROM employees
WHERE hire_date>=
Question text
TO_DATE('2000', 'YYYY') AND hire_date<=
John want to know how many employees receiving TO_DATE('2006', 'YYYY') OR salary > 5000;
salary below 10,000.
What SQL command he need to run? Question 14
Complete
Select one: Mark 2.00 out of 2.00
Flag question
a. SELECT COUNT(*) FROM employees WHERE salary
< 10000; Question text
b. SELECT COUNT(salary) FROM employees WHERE
salary < 10,000; List all employees except for IT_PROG job id.
c. SELECT COUNT(emp_id) FROM employees WHERE
Select one:
salary <= 10000;
a. SELECT *FROM employees EXCEPT JOB_ID !=
d. SELECT salary FROM COUNT(employees)WHERE
'IT_PROG'
salary < 10000;
b. SELECT *FROM employees WHERE JOB_ID NOT IN
Question 12
('IT_PROG')
Complete c. SELECT *FROM employees WHERE JOB_ID <>
Mark 2.00 out of 2.00 'IT_PROG'
d. All of the choices Question 18
Complete
Question 15 Mark 2.00 out of 2.00
Complete Flag question
Mark 2.00 out of 2.00
Flag question Question text
Question text You what to generate the average salary of all
employees whose job function is FI_ACCOUNT.
Evaluate the following SQL command Which of the following SQL command will produce the
SELECT employee_id, min_salary, max_salary output.
FROM employees, departments WHERE
salary>= 10000 && salary <= 20000 Select one:
a. SELECT AVERAGE(salary) FROM employees WHERE
Select one: job_id = 'FI_ACCOUNT';
a. The SQL will produce Cartesian Product b. SELECT AVG(salary) FROM employees WHERE
b. The SQL will display the employee id, department id job_id = 'FI_ACCOUNT';
and the minimum and maximum salary whose salary c. SELECT AVE(salary) FROM employees WHERE
is between 10000 and 20000. job_id = 'FI_ACCOUNT';
c. The SQL command will produce an error. d. SELECT COUNT AVG(salary) FROM employees
d. The SQL command will give an incorrect output. WHERE job_id = 'FI_ACCOUNT';
Question 16 Question 19
Complete Complete
Mark 2.00 out of 2.00 Mark 2.00 out of 2.00
Flag question Flag question
Question text Question text
Display all the records in the employee table. Arrange Display all location id between 1000 to 2000.
the output in by lastname from A-Z order.
Select one:
Select one: a. DISPLAY location_id FROM departments WHERE
a. SELECT * FROM employees SORT BY lastname location_id LING 1000 UP TO 2000
b. SELECT * FROM employees ORDER BY lastname b. DISPLAY location_id FROM departments WHERE
c. SELECT * FROM employees ORDER BY lastname AZ location_id BETWEEN 1000 TO 2000
d. SELECT * FROM employees SORT BY lastname c. SELECT location_id FROM departments WHERE
ascending location_id IN 1000 AND 2000
d. SELECT location_id FROM departments WHERE
Question 17
Complete
location_id BETWEEN 1000 AND 2000
Mark 2.00 out of 2.00
Flag question Question 20
Complete
Question text Mark 2.00 out of 2.00
Flag question
Display employee's name and id whose firstname
starts with letter D and job id is IT_PROG. Question text
Sort the output by department. What will be the SQL command if every employee will
Select one: be given a productivity bonus which is equivalent to
a. SELECT employee_id, first_name, last_name FROM 3% of the monthly salary?
employees ORDER BY department_id WHERE Display the employee id, salary and the productivity
first_name LIKE 'D%' and job_id = 'IT_PROG' bonus.
b. SELECT employees FROM employee_id, first_name, Select one:
last_name WHERE first_name LIKE ‘D%’ and job_id a. SELECT employee_id, salary, salary + (salary .03)
= ‘IT_PROG’ ORDER BY department_id FROM employees
c. SELECT employee_id, first_name, last_name FROM b. SELECT employee_id, salary, salary * .03 FROM
employees WHERE job_id = 'IT_PROG' OR employees
first_name LIKE 'D%' and ORDER BY department_id c. SELECT employee_id, salary, salary * 1.03 FROM
d. SELECT employee_id, first_name, last_name FROM employees
employees WHERE first_name LIKE 'D%' and job_id d. SELECT employee_id, salary FROM employees
= 'IT_PROG' ORDER BY department_id WHERE salary)
e. SELECT employee_id, salary, salary * .30 FROM Question 23
employees Complete
Mark 2.00 out of 2.00
Question 21 Flag question
Complete
Mark 2.00 out of 2.00 Question text
Flag question
In creating Joins,the NATURALJOIN and USING
Question text clauses are____________
Display the employee id, salary, number of years and Select one:
the hiring date of every employee in the company. a. Mutually Inclusive
b. Limited to 2 relational tables
Select one: c. Opposite
a. SELECT employee_id,salary, hire_date, hire_date- d. Mutually Exclusive
SYSDATE /365 FROM employees;
b. SELECT employee_id, salary, hire_date, Question 24
ROUND((SYSDATE - hire_date) /365,0) FROM Complete
employees; Mark 4.00 out of 4.00
c. SELECT employee_id, salary, hire_date, hire_date Flag question
/365 FROM employees; Question text
Question 22 Display employee id, lastname, firstname, department
Complete name, annual salary, location id of employees whose
Mark 2.00 out of 2.00
Flag question
location id is 1700 and working in Finance
Department. Label the annual salary to ANNUAL
Question text SALARY.
Sort the output in from highest to lowest salary. (4
Display the employee's name, job title, job_id and the POINTS)
department name of employees with department id of
100. Select one:
a. SELECT E.employee_id, E.last_name, E.first_name,
Select one: D.department_name, E.salary*12 AS "ANNUAL
a. SELECT E.employee_id, J.job_title, e.job_id, SALARY", D.location_id
D.department_name FROM employees E
FROM employees E NATURAL JOIN jobs J ON E.job_id = J.job_id
JOIN jobs J ON E.job_id = J.job_id NATURAL JOIN departments D ON E.department_id
JOIN departments D ON E.department_id = = D.department_id
D.department_id ORDER BY "ANNUAL SALARY" DESC
WHERE E.department_id = 100 WHERE D.location_id = 1700 AND
b. SELECT E.employee_id, J.job_title, e.job_id, D.department_name = 'Finance'
D.department_name b. SELECT E.employee_id, E.last_name, E.first_name,
FROM employees E D.department_name, E.salary*12 AS "ANNUAL
JOIN department D ON E.job_id = J.job_id SALARY", D.location_id
JOIN jobs J ON E.department_id = D.department_id FROM employees E
WHERE E.department_id = 100 JOIN jobs J ON E.job_id = J.job_id
c. SELECT E.employee_id, J.job_title, e.job_id, JOINemployees E ON E.department_id =
D.department_name D.department_id
FROM jobs J WHERE D.location_id = 1700 AND
INNER JOIN department D ON E.job_id = J.job_id D.department_name = 'Finance'
INNER JOIN employees EON E.department_id = ORDER BY "ANNUAL SALARY" DESC
D.department_id c. SELECT E.employee_id, E.last_name, E.first_name,
WHERE E.department_id = 100 D.department_name, E.salary*12 AS "ANNUAL
d. SELECT E.employee_id, J.job_title, e.job_id, SALARY", D.location_id
D.department_name FROM employees E
FROM jobs J JOIN jobs J ON E.job_id = J.job_id
NATURAL JOIN department D ON E.job_id = J.job_id JOIN departments D ON E.department_id =
NATURAL JOIN employees E ON E.department_id = D.department_id
D.department_id WHERE D.location_id = 1700 AND
WHERE E.department_id = 100 D.department_name = 'Finance'
ORDER BY "ANNUAL SALARY" DESC
d. SELECT E.employee_id, E.last_name, E.first_name, SELECT * FROM parts WHERE onhand< 20 AND
D.department_name, E.salary*12 AS "ANNUAL warehouse = 3;
SALARY", D.location_id
FROM employees E Ronnie is the stockman in the warehouse of ATR
OUTER JOIN jobs J ON E.job_id = J.job_id
Corporation. The General Manager wants to know the
OUTER JOIN departments D ON E.department_id =
D.department_id parts whose price is above 10000 and above. Which of
WHERE D.location_id = 1700 AND the following SQL command that Ronnie will run to
D.department_name = 'Finance' generate the list.
ORDER BY "ANNUAL SALARY" DESC SELECT * FROM parts WHERE price >= 10000;
List all the employee_id of all employees whose salary is Every employee will get a bonus of 150% of his/her
5000 and below and belong to department 60 or 100. current salary. Display the employee id, salary and the
SELECT employee_id,salary, department_id FROM bonus of every employee. Label the computed bonus
employees WHERE salary < 5000 AND department_id with Bonus
IN (60,100) The correct answer is: SELECT employee_id, salary,
salary * 1.5 AS Bonus FROM employees
---------------------------------------- ----------------------------------------
SQ2 SQ3
Display all the records sorted by price from most Display the montly salary of every employee. Round the
expensive to the cheapest parts. salary in 2 decimal places.
SELECT * FROM parts ORDER BY price DESC SELECT ROUND( (salary/12),2 ) FROM employees;
Display all the records whose stock is below 20 and in Display the total number of characters of the last name
warehouse number 3. of all the employees.
SELECT LENGTH(last_name) FROM employees; id is AD_VP. Which SQL statement give the required
output?
Display the first 3 letter in the first name of all the SELECT employee_id, hire_date,
employees. TO_CHAR(hire_date,'Month') AS "Hired Month",
SELECT SUBSTR(first_name,1,3) FROM employees; job_id FROM employees WHERE job_id NOT IN
('AD_VP');
Display the last day of the month and the hiring date
when the employees are hired in the company. You want to display the employee's id and formatted
SELECT LAST_DAY(hire_date), hire_date FROM date hired as shown below.
employees; Which SQL statement give the required output?
Required output :
---------------------------------------- SELECT employee_id, TO_CHAR(hire_date, 'fmMonth
LA4 DD, YYYY') AS "Hired Date" FROM employees;
----------------------------------------
You want to display the employee id and the year when LA5
an employee was hired.
Which SQL statement give the required output?
SELECT employee_id, TO_CHAR(hire_date,'YYYY') The General Manager request to the Database
FROM employees; Administrator to generate the total salary per month of
every department in the company.
You want to display the employee id and the month an SELECT department_id, SUM(salary) FROM employees
employee was hired. GROUP BY department_id
Which SQL statement give the required output?
SELECT employee_id, hire_date, Ms. Ella what to generate the average salary of all
TO_CHAR(hire_date,'Month') AS "Hired Month" FROM employees whose job function is IT_PROG.
employees; Which of the following SQL command will produce the
output.
You want to display the employee's last name whose SELECT AVG(salary) FROM employees WHERE job_id =
salary is below 10,000. 'IT_PROG';
Which SQL statement give the required output format
of the salary? Aldrin wants to know the highest salary in every
Required output : department. Which of the following SQL command will
SELECT last_name, TO_CHAR(salary, '$999,999.99') AS display the required output?
"MONTHLY SALARY" FROM employees WHERE salary < SELECT department_id, MAX(salary) FROM employees
10000 GROUP BY department_id
You want to display all the employee id and the month John want to know how many part items are there in
an employee was hired excluding employees whose job warehouse number 3.
What SQL command he need to run? (job_id);
SELECT COUNT(*) FROM parts WHERE warehouse = 3;
Which of the following SQL command will display all What will be the output of the SQL command below?
records with part number contains the number 9? SELECT first_name, last_name, job_title FROM
SELECT * from parts WHERE partnum LIKE '%9%' employees CROSS JOIN jobs ORDER BY last_name;
A Cartesian product
What will be the output of the following SQL? What will be the output of the SQL command below?
SELECT * FROM parts WHERE (warehouse = 1 or SELECT last_name, job_id, job_title FROM employees
warehouse = 2) AND class IN ('HW', 'AP') AND (price > NATURAL JOIN jobs
200 AND price < 500); List of names and job title of matched records from the
2 rows returned employees and jobs table
----------------------------------------
What will be the output of the SQL command? SQ6
SELECT SUM(onhand) FROM PARTS where class = 'HW'
OR class = 'AP' AND warehouse = 1;
137 Given the SQL command
SELECT * FROM employees JOIN departments USING
There was 10% price increase in the all the parts in (department_id)
warehouse number 3. The Store Manager asked the Which of the following describes the SQL command?
Database Administrator to generate a report showing Joined table from the employees and department
the part number, the old and new price. table
Which of the following SQL statement would satisfy the
requirement of the Store Manager.
SELECT partnum, price, price * 1.1 FROM parts WHERE Display the location id of all employee's name and
warehouse = 3 salary whose salary is from 5000 to 10000.
SELECT first_name, last_name, salary FROM
Which of the following SQL command will display the employees JOIN departments USING (department_id)
summary table showing the total quantity on hand per WHERE salary >= 5000 AND salary <= 10000
class.
SELECT class, sum(onhand) AS "QTY ON HAND" FROM Display the manager id and employee id of every
parts GROUP BY class employee
SELECT E.employee_id, D.manager_id FROM
employees E JOIN departments D ON E.department_id
Aldrin wants to know the outstanding total balance on = D.department_id
hand on every class per warehouse.
SELECT warehouse, class, sum(onhand) FROM parts Given the SQL command
GROUP BY warehouse, class SELECT employees.first_name, employees.last_name,
employees.salary,departments.department_name
---------------------------------------- FROM employees, departments
LA6 WHERE employees.department_id =
departments.department_id;
Which of the following describes the SQL command?
List of employees name, salary and department name
TRUE OR FALSE.
Add a 500 pesos increase in salary of all employees who An owner has all the privileges on the object.
have rendered services 10 years and above. True
UPDATE employees SET salary = salary + 500 where
TO_CHAR(sysdate,'YYYY') - TO_CHAR(hire_date,'YYYY') Which of the following provide privilege to update the
>= 10 employees table?
GRANT update (salary) ON employees TO matt
Which of the following DOES NOT describes the state of Which of the following will is the correct command to
the data after the COMMIT command create a role.
None of the choices CREATE ROLE gen_manager
Which of the following describes the command below? Matt wants to change his password from 1234 to abcd.
SELECT * FROM employees WHERE department = 60 Which of the following will perform the task?
FOR UPDATE ALTER USER matt IDENTIFIED abcd;
Locks the rows in the EMPLOYEES table with
department id is 60. The DBA will create a new user name sales.
Which of the following SQL command will perform the
Which of the following will erase all records in the creation?
departments table CREATE sales ACCESS 1234
TRUNCATE TABLE departments
Which of the following SQL command that the DBA will
run to provide Matt to create a table in the Oracle You want to display all the job position titles whose
Database. salary is salary from 5,000 to 12,000 arrange from
GRANT create table TO matt highest to lowest
SELECT job_title FROM jobs WHERE min_salary >=
5000 AND max_salary<= 10000
What privileges that manipulates the content of the
database objects. List all employees except for IT_PROG job id.
Object Privileges All of the choices
Evaluate the following SQL command Display the lastname of every employee in the
SELECT employee_id, salary, department_id FROM company. Display the output in a single column and
employees WHERE department_id IN (60,70) label it as Fullname
The SQL command will display employees with Format: JuanReyes
department id 60 or 70. SELECT CONCAT(first_name, last_name) AS Fullname
FROM employees
True or False. The AND, OR, NOT are comparison
operators. Evaluate the following SQL command
False SELECT * FROM jobs WHERE job_title LIKE 'Manager%'
No records will be displayed
What is the SQL command to count the number of
records in the employees table?
SELECT COUNT(*) FROM employees Display all the records in the employee table. Arrange
the output in by lastname from A-Z order.
SELECT * FROM employees ORDER BY lastname
What will be the SQL command if every employee will
be given a productivity bonus which is equivalent to 3% You want to generate the total salary per month of
of the monthly salary? every department in the company.
Display the employee id, salary and the productivity SELECT department_id, SUM(salary) FROM employees
bonus. GROUP BY department_id
SELECT employee_id, salary, salary * .03 FROM
employees You want to display the employee's last name whose
salary is below 10,000 and whose lastname starts with
Display the employee id, salary, number of years and letter D.
the hiring date of every employee in the company. Which SQL statement give the required output format
SELECT employee_id, salary, hire_date, of the salary?
ROUND((SYSDATE - hire_date) /365,0) FROM SELECT last_name, TO_INTEGER(salary, $999,999.99)
employees; AS "MONTHLY SALARY" FROM employees WHERE
salary < 10000 WHERE last_name IN 'D%'
You what to generate the average salary of all
employees whose job function is FI_ACCOUNT.
Which of the following SQL command will produce the In creating Joins,the NATURALJOIN and USING clauses
output. are____________
SELECT AVG(salary) FROM employees WHERE job_id = Mutually Exclusive
'FI_ACCOUNT';
Display employee id, lastname, firstname, department Answer: SQL code are embedded within
name, annual salary, location id of employees whose PL/SQL statements
location id is 1700 and working in Finance Department. When an exception is user defined, the
Label the annual salary to ANNUAL SALARY. exception is raised ____________ .
Sort the output in from highest to lowest salary. (4 Answer: Explicitly
POINTS) Which of the folllowing is TRUE?
SELECT E.employee_id, E.last_name, E.first_name, Answer: SQL code are embedded withing
D.department_name, E.salary*12 AS "ANNUAL PL/SQL statements
SALARY", D.location_id Weak REF CURSOR is very flexible.
FROM employees E Answer: True
JOIN jobs J ON E.job_id = J.job_id How do you test the output of a PL/SQL
JOIN departments D ON E.department_id = block?
D.department_id
Answer: Use a predefined Oracle package
WHERE D.location_id = 1700 AND D.department_name
and its procedure
= 'Finance'
Restrictive, specifies a RETURN type,
ORDER BY "ANNUAL SALARY" DESC
associates only with type-compatible
queries are description of a ________________.
Answer: Strong REF CURSOR
Which of the following DOES NOT describes
an exception?
Which of the following does NOT describes Answer: Exception is a PL/SQL error that is
SELECT Statement in a PL/SQL. raised before program execution.
Answer: Queries must return only one These are local variables declared in the
column. parameter list of a subprogram
You want to display all the records of specification.
employee the same with the salary Answer: Formal parameter
employee number 103. Which of the following rules is INCORRECT
Answer: SELECT * FROM employees about cursor variables?
WHERE salary = (SELECT salary from Answer: None of the choices.
employees where employee_id= 103) When an exception is predefined by Oracle
Which of the following stored procedure to server, the exception is raised ____________ .
create a procedure to that will be used to Answer: Explicitly
display the employee id and salary of Which of the following DOES NOT describes
Steven King? an exception?
Answer: CREATE OR REPLACE PROCEDURE Answer: Exception is a PL/SQL error that is
query_emp raised before program execution.
(p_last_name IN employees.last_name Evaluate the following PL/SQL.
%TYPE, CREATE OR REPLACE PROCEDURE
p_first_name IN employees.first_name query_employee
%TYPE, (p_id IN employees.employee_id%TYPE,
p_employee_id OUT employees.employee_id p_name OUT employees.last_name%TYPE,
%TYPE, p_salary OUT employees.salary%TYPE) IS
p_salary OUT employees.salary%TYPE) IS BEGIN SELECT last_name, salary INTO
BEGIN p_name, p_salary
SELECT employee_id, salary INTO FROM employeesWHERE employee_id =
p_employee_id, p_salary p_id;
FROM employees END query_employee
WHERE last_name = p_last_name AND Answer: No error
first_name = p_first_name; You want to know the total number of
END query_emp; employees whose firstname starts with
Which of the folllowing is TRUE? letter D.
Which of the folllowing PLS/SQL executes CURSOR?
successfully? Answer: Associates with any query
Answer: DECLARE Given the answer in item __________, which
v_first_name employees.first_name of the folllowing stored procedure will
%TYPE := 'D%'; display the employee id and salary of
BEGIN Steven King?
SELECT COUNT(*) INTO v_first_name FROM Answer: DECLARE
employees WHERE first_name LIKE v_employee_id employees.employee_id
v_first_name; %TYPE;
DBMS_OUTPUT.PUT_LINE(v_first_name); v_emp_sal employees.salary%TYPE;
END; BEGIN
What is the error trapping function that query_emp('King', 'Steven', v_employee_id,
returns the numeric value of the error v_emp_sal);
code? DBMS_OUTPUT.PUT_LINE('Employee ID ' ||
Answer: SQLCODE v_employee_id ||' earns '||
You want to display the name, salary and to_char(v_emp_sal, '$999,999.00'));
tax of employee #150. Which of the PL/SQL END;
will execute successfully? Note tax is You have been tasked to update the
computed as 2% of the salary. database by creating a PL/SQL to increase
Answer: DECLARE the salary of all IT Programmer employees
v_first_name VARCHAR2(50); by 50% of their existing salary.
v_last_name VARCHAR2(50); Which of the following will execute
v_salary INTEGER(20); successfully?
v_tax INTEGER(10); Answer: DECLARE
BEGIN v_job_id employees.job_id%TYPE :=
SELECT first_name, last_name, salary, 'IT_PROG';
salary * 0.02 INTO v_first_name, BEGIN
v_last_name, v_salary, v_tax FROM UPDATE employees SET salary = salary
employees WHERE employee_id = 150; *0.50 WHERE job_id = v_job_id;
DBMS_OUTPUT.PUT_LINE('Firstname : '|| END;
v_first_name); Which of the folllowing is required in a
DBMS_OUTPUT.PUT_LINE('Lastname : '|| subquery?
v_last_name); Answer: SELECT
DBMS_OUTPUT.PUT_LINE('Salary : '|| What is the exception name when PL/SQL
v_salary); has an internal problem
DBMS_OUTPUT.PUT_LINE('Tax : '|| v_tax); Answer: PROGRAM_ERROR
END; In the DECLARE section of the PL/SQL
Which of the following is the syntax to block,
close a cursor? Answer: All of the choices
Answer: CLOSE cursor_variable_name; Actions are being performed when error
Which of the following rules is INCORRECT occurs during PL/SQL execution in the
about cursor variables? Answer: EXCEPTION
Answer: None of the choices. What is the exception name when PL/SQL
What are the three PL/SQL block types? has an internal problem
Answer: Anonymous, Procedure, Function Answer: PROGRAM_ERROR
You can trap any error by including a Which of the folllowing statement
corresponding handler within the describes PL/SQL?
exception-handling section of the PL/SQL Answer: PL/SQL is an Oracle proprietary,
block. procedural, 3GL programming language
Answer: True Evaluate the following PL/SQL.
Which of the following describes weak REF DECLARE
v_employee_id employees.employee_id In PL/SQL Block Structure, which of the
%TYPE := 114; following are mandatory?
BEGIN Answer: BEGIN and END
DELETE employees WHERE employee_id = PL/SQL stands for
v_employee_id; Answer: Procedural Language extension to
END; SQL
Answer: The PL/SQL will delete employee Which of the following is CORRECT about
number 114. sub-queries?
Which of the following command is used to Answer: Subquery execute before the main
create a stand-alone procedure that is query executes.
stored in the Oracle database? Which of the following does NOT describes
Answer: CREATE PROCEDURE SELECT Statement in a PL/SQL.
Evaluate the following PL/SQL. Answer: Queries must return only one
DECLARE column.
v_email VARCHAR(20); PL/SQL Provides a block structure for
BEGIN executable units of ________________.
SELECT email INTO v_email FROM Answer: Code
EMPLOYEES WHERE email like 'D%'; Evaluate the SQL command
DBMS_OUTPUT.PUT_LINE ('Employees SELECT employee_id, salary from
whose email address starts with letter D :' employees where salary = ANY (SELECT
|| v_email); salary FROM employees WHERE job_id =
EXCEPTION 'IT_PROG') AND job_id = 'ST_CLERK'
WHEN TOO_MANY_ROWS THEN Answer: This has no error.
DBMS_OUTPUT.PUT_LINE (' Your select Which of the following PL/SQL will execute
statement retrieved multiple rows.'); successfully?
END; Answer: DECLARE
Answer: The PL/SQL block will run v_salary INTEGER(20);
successfully. BEGIN
Which of the following is the syntax to SELECT salary INTO v_salary FROM
define a REF CURSOR type? employees WHERE employee_id = 150;
Answer: TYPE ref_type_name IS REF END;
CURSOR In PL/SQL Block Structure, which of the
[RETURN return_type]; following are OPTIONAL?
The PL/SQL code block helps modularize Answer: None of the choices
code by using: Evaluate the following PL/SQL. At what line
Answer: All of the choices number is the error of the PL/SQL?
Which of the following is the syntax to DECLARE
fetch from a cursor variable? v_deptno NUMBER := 800;
Answer: FETCH cursor_variable_name INTO e_invalid EXCEPTION;
variable_name1 BEGIN
[,variable_name2,. . .] | record_name; DELETE FROM departments
You want to display all records in the WHERE department_id = v_deptno;
database whose salary is above the salary IF SQL % NOT_FOUND THEN
of Alexander Hunold. RAISE e_invalid;
Answer: SELECT * from employees WHERE END IF;
salary < (SELECT salary FROM employees COMMIT;
WHERE first_name = 'Alexander' AND EXCEPTION
last_name = 'Hunold') WHEN e_invalid THEN
Procedure can be stored in the database as DBMS_OUTPUT.PUT_LINE('No such
a schema object. department id.');
Answer: True END;
Answer: 7 Use column aliases in cursors for calculated columns
What is the error trapping function that fetched into records declared with %COLUMNTYPE.
returns the numeric value of the error Answer: False
code?
Answer: SQLCODE PROG-113A / ► Week 18: Designing PL/SQL / ►
Fetch into a record when fetching from a Learning Activity 14
cursor.
Answer: True Which of the following rules is INCORRECT about
cursor variables?
Answer: None of the choices.
Which of the following is the syntax to open a cursor Which of the following describes weak REF
varial CURSOR?
Answer: OPEN cursor_variable_name Answer: Associates with any query
FOR select_statement; Restrictive, specifies a RETURN type, associates
Which of the following is the syntax to define a REF only with type-compatible queries are description of
CURSOR type? a ________________.
Answer: TYPE ref_type_name IS REF CURSOR Answer: Strong REF CURSOR
[RETURN return_type]; Which of the following is INCORRECT about the
Weak REF CURSOR is very flexible. guidelines for cursor design?
Answer: True Answer: Use column aliases in cursors for
Evaluate the following. What will be the output? calculated columns fetched into records declared
DECLARE with %COLUMNTYPE.
SUBTYPE Accumulator IS NUMBER (4,2); This is a subset of an existing data type that may
v_amount accumulator; place a constraint on its base type.
v_num1 NUMBER; Answer: Subtype
v_num2 NUMBER;
v_num3 NUMBER;
BEGIN
v_amount := 10.50; PROG-113A / ► Week 17: / ► Short Quiz 13
v_num1 := 1; Evaluate the following PL/SQL.
v_num2 := 2;
CREATE OR REPLACE PROCEDURE
v_num3 := 3;
query_employee
v_num1 := v_amount;
(p_id IN employees.employee_id%TYPE,
v_num2 := v_num1 + v_amount;
p_name OUT employees.last_name%TYPE,
v_num2 := v_num2 - v_num3;
p_salary OUT employees.salary%TYPE) IS
dbms_output.put_line('Total is: ' || v_num2);
BEGIN SELECT last_name, salary INTO p_name,
END;
Answer: 18
p_salary
Which of the following is the syntax to fetch from a FROM employeesWHERE employee_id = p_id;
cursor variable? END query_employee
Answer: FETCH cursor_variable_name INTO Answer: No error
variable_name1 Evaluate the following PL/SQL. Which of the
[,variable_name2,. . .] | record_name; following will line creates an error?
Fetch into a record when fetching from a cursor. CREATE OR REPLACE PROCEDURE
Answer: True query_emp
Which of the following is the syntax to close a cursor? (
Answer: CLOSE cursor_variable_name; p_department_id IN employees.department_id
This is a subset of an existing data type that may place a %TYPE,
constraint on its base type. p_name OUT employees.last_name%TYPE,
Answer: Subtype p_salary OUT employees.salary%TYPE
Which of the following rules is INCORRECT about cursor )
variables? IS
Answer: None of the choices. BEGIN
SELECT last_name, salary, department_id INTO Answer: All of the choices
p_name, p_salary, p_department_id Which of the following command is used to create a
FROM employees stand-alone procedure that is stored in the Oracle
WHERE salary >= p_salary AND department_id = database?
p_department_id ; Answer: CREATE PROCEDURE
END query_emp; Which of the folllowing does NOT describes
Answer: Line 3 subprogram?
These are local variables declared in the parameter i. Compiled only once
list of a subprogram specification. ii. Stored in the database
Answer: Formal parameter iii. Do not return values
Given the answer in item __________, which of the
iv. Can take parameters
folllowing stored procedure will display the
v. Unnamed PL/SQL blocks
employee id and salary of Steven King?
Answer: iii & v
Answer: DECLARE
v_employee_id employees.employee_id%TYPE; Which if the following is NOT a benefits of using
v_emp_sal employees.salary%TYPE; modular program constructs?
BEGIN Answer: None of the choices
query_emp('King', 'Steven', v_employee_id, PROG-113A / ► Week 18: Designing PL/SQL / ► Short
v_emp_sal); Quiz 14
DBMS_OUTPUT.PUT_LINE('Employee ID ' ||
Which of the following is the syntax to open a cursor
v_employee_id ||' earns '|| to_char(v_emp_sal,
varial
'$999,999.00'));
Answer: OPEN cursor_variable_name
END;
FOR select_statement;
Which of the following stored procedure to create a Which of the following is the syntax to define a REF
procedure to that will be used to display the CURSOR type?
employee id and salary of Steven King? Answer: TYPE ref_type_name IS REF CURSOR
Answer: CREATE OR REPLACE PROCEDURE [RETURN return_type];
query_emp Weak REF CURSOR is very flexible.
(p_last_name IN employees.last_name%TYPE, Answer: True
p_first_name IN employees.first_name%TYPE, Evaluate the following. What will be the output?
p_employee_id OUT employees.employee_id DECLARE
%TYPE, SUBTYPE Accumulator IS NUMBER (4,2);
p_salary OUT employees.salary%TYPE) IS v_amount accumulator;
BEGIN v_num1 NUMBER;
SELECT employee_id, salary INTO v_num2 NUMBER;
p_employee_id, p_salary v_num3 NUMBER;
FROM employees BEGIN
WHERE last_name = p_last_name AND first_name v_amount := 10.50;
= p_first_name; v_num1 := 1;
END query_emp;
v_num2 := 2;
What is the default parameter mode when no mode
v_num3 := 3;
is specified?
v_num1 := v_amount;
Answer: IN
v_num2 := v_num1 + v_amount;
PROG-113A / ► Week 16: Creating Procedures / ► v_num2 := v_num2 - v_num3;
Learning Activity 13 dbms_output.put_line('Total is: ' || v_num2);
Procedure can be stored in the database as a schema END;
object. Answer: 18
Answer: True Which of the following is the syntax to fetch from a
The PL/SQL code block helps modularize code by using: cursor variable?
Answer: FETCH cursor_variable_name INTO
variable_name1 In PL/SQL Block Structure, which of the following
[,variable_name2,. . .] | record_name; are mandatory?
Fetch into a record when fetching from a cursor. Answer: BEGIN and END
Answer: True This is a type of cursor which is created and
Which of the following is the syntax to close a cursor? managed internally by the Oracle server to process
Answer: CLOSE cursor_variable_name; SQL statements
This is a subset of an existing data type that may place a Answer: Implicit
constraint on its base type. PL/SQL stands for
Answer: Subtype Answer: Procedural Language extension to SQL
Which of the following rules is INCORRECT about cursor
Which of the following PL/SQL will execute
successfully?
variables?
Answer: DECLARE
Answer: None of the choices.
v_salary INTEGER(20);
Use column aliases in cursors for calculated columns
BEGIN
fetched into records declared with %COLUMNTYPE. SELECT salary INTO v_salary FROM employees
Answer: False WHERE employee_id = 150;
END;
PROG-113A / ► Week 18: Designing PL/SQL / ► What is the last clause in trapping exceptions?
Learning Activity 14 Answer: WHEN OTHERS
PL/SQL Provides a block structure for executable
Which of the following rules is INCORRECT about units of ________________.
cursor variables? Answer: Code
Answer: None of the choices. Evaluate the following PL/SQL.
Which of the following describes weak REF DECLARE
CURSOR? v_email VARCHAR(20);
Answer: Associates with any query BEGIN
Restrictive, specifies a RETURN type, associates SELECT email INTO v_email FROM
only with type-compatible queries are description of EMPLOYEES WHERE email like 'D%';
a ________________. DBMS_OUTPUT.PUT_LINE ('Employees whose
Answer: Strong REF CURSOR email address starts with letter D :'
Which of the following is INCORRECT about the || v_email);
guidelines for cursor design? EXCEPTION
Answer: Use column aliases in cursors for WHEN TOO_MANY_ROWS THEN
calculated columns fetched into records declared DBMS_OUTPUT.PUT_LINE (' Your select
with %COLUMNTYPE. statement retrieved multiple rows.');
This is a subset of an existing data type that may END;
place a constraint on its base type. Answer: The PL/SQL block will run successfully.
Answer: Subtype Which of the folllowing is TRUE?
Answer: SQL code are embedded within PL/SQL
PROG-113A / ► Week 15: Long Quiz / ► Long statements
Quiz 3 (30/30) You can trap any error by including a corresponding
(Correction) handler within the exception-handling section of the
How do you test the output of a PL/SQL block? PL/SQL block.
Answer: Use a predefined Oracle package and its Answer: True
procedure When an exception is user defined, the exception is
Which of the folllowing statement describes raised ____________ .
PL/SQL? Answer: Explicitly
Answer: PL/SQL is an Oracle proprietary, Evaluate the PL/SQL
procedural, 3GL programming language DECLARE
Which of the following syntax to declare v_first_name VARCHAR2(50);
EXCEPTION named e_invalid_id? v_last_name VARCHAR2(50);
Answer: e_invalid_id EXCEPTION; v_salary INTEGER(20);
BEGIN v_employee_id employees.employee_id%TYPE :=
SELECT first_name, last_name, salary INTO 114;
v_first_name, v_last_name, v_salary FROM BEGIN
employees WHERE department_id = 60; DELETE employees WHERE employee_id =
DBMS_OUTPUT.PUT_LINE('Firstname : '|| v_employee_id;
v_first_name); END;
DBMS_OUTPUT.PUT_LINE('Lastname : '|| Answer: The PL/SQL will delete employee number
v_last_name); 114.
DBMS_OUTPUT.PUT_LINE('Salary : '|| v_salary); In the DECLARE section of the PL/SQL block,
END; Answer: All of the choices
Answer: Error in Line 6. When an exception is predefined by Oracle server,
Evaluate the following PL/SQL. the exception is raised ____________ .
DECLARE Answer: Explicitly
v_employee_id employees.employee_id%TYPE := Which of the will display the Employee ID and
114; number of years in service with employee ID 150?
BEGIN Answer: DECLARE
DELETE employees WHERE employee_id = v_salaryemployees.salary%TYPE := 10000;
v_employee_id; v_employee_idemployees.employee_id%TYPE :=
END; 150;
Answer: The PL/SQL will delete employee number v_years INTEGER(10);
114. BEGIN
Which of the following does NOT describes SELECT employee_id, ROUND((SYSDATE -
SELECT Statement in a PL/SQL. hire_date) /365,0) INTO v_employee_id, v_years
Answer: Queries must return only one column. FROM employees WHERE employee_id =
What are the three PL/SQL block types? v_employee_id ;
Answer: Anonymous, Procedure, Function DBMS_OUTPUT.PUT_LINE('Employee ID:' ||
What is the exception name when PL/SQL has an v_employee_id);
internal problem DBMS_OUTPUT.PUT_LINE('Number of years : '
Answer: PROGRAM_ERROR || v_years);
You have been tasked to update the database by END;
creating a PL/SQL to increase the salary of all IT Actions are being performed when error occurs
Programmer employees by 100% of their existing during PL/SQL execution in the
salary. Which of the following will execute Answer: EXCEPTION
successfully? You can use this procedure to issue user-defined
Answer: DECLARE error messages from stored subprograms.
v_job_id employees.job_id%TYPE := 'IT_PROG'; Answer: RAISE_APPLICATION_ERROR
BEGIN
UPDATE employees SET salary = salary * 2
WHERE job_id = v_job_id;
END; PROG-113A / ► Week 14: Handling Exceptions /
What is the error trapping function that returns the ► Short Quiz 12
numeric value of the error code?
Answer: SQLCODE Evaluate the following PL/SQL.
What is the exception name when single row DECLARE
SELECT returned no data. v_email VARCHAR(20);
Answer: NO_DATA_FOUND BEGIN
Which of the following DOES NOT describes an SELECT email INTO v_email FROM
exception? EMPLOYEES WHERE email like 'D%';
Answer: Exception is a PL/SQL error that is raised DBMS_OUTPUT.PUT_LINE ('Employees whose
before program execution. email address starts with letter D :'
Evaluate the following PL/SQL. || v_email);
DECLARE EXCEPTION
WHEN TOO_MANY_ROWS THEN EXCEPTION named e_invalid_id?
DBMS_OUTPUT.PUT_LINE (' Your select Answer: e_invalid_id EXCEPTION;
statement retrieved multiple rows.'); When an exception is predefined by Oracle server,
END; the exception is raised ____________ .
Answer: The PL/SQL block will run successfully. Answer: Explicitly
Which of the following DOES NOT describes an When an exception is user defined, the exception is
exception? raised ____________ .
Answer: Exception is a PL/SQL error that is raised Answer: Explicitly
before program execution. You can trap any error by including a corresponding
What is the exception name when single row handler within the exception-handling section of the
SELECT returned no data. PL/SQL block.
Answer: NO_DATA_FOUND Answer: True
RAISE_APPLICATION_ERROR is used in two
different places. These are ___________________. PROG-113A / ► Week 13: Interacting with Oracle
Answer: Executable and exceptions section Server / ► Learning Activity 11
What is the error trapping function that returns the
numeric value of the error code? Which of the following does NOT describes
Answer: SQLCODE SELECT Statement in a PL/SQL.
What is the exception name when PL/SQL has an Answer: Queries must return only one column.
internal problem Evaluate the following PL/SQL.
Answer: PROGRAM_ERROR 1 DECLARE
Evaluate the following PL/SQL. At what line
number is the error of the PL/SQL? 2 v_employee_id employees.employee_id
DECLARE %TYPE := 114;
v_deptno NUMBER := 800;
e_invalid EXCEPTION; 3 BEGIN
BEGIN
DELETE FROM departments 4 DELETE employees WHERE employee_id =
WHERE department_id = v_deptno; v_employee_id;
IF SQL % NOT_FOUND THEN
RAISE e_invalid; 5 END;
END IF; Answer: The PL/SQL will delete employee number
COMMIT; 114.
EXCEPTION Which of the following PL/SQL that will display
WHEN e_invalid THEN the total number employees whose salary is 10000
DBMS_OUTPUT.PUT_LINE('No such department and above?
id.'); Answer: DECLARE
END; v_salary employees.salary%TYPE := 10000;
Answer: 7 BEGIN
What is the last clause in trapping exceptions? SELECT COUNT(*) INTO v_salary FROM
Answer: WHEN OTHERS employees WHERE salary >= v_salary;
Complete the diagram in Trapping Non-Predefined DBMS_OUTPUT.PUT_LINE(v_salary);
Oracle Server Errors. END;
Answer: Declare, Associate, Reference This is a type of cursor which is created and
managed internally by the Oracle server to process
PROG-113A / ► Week 14: Handling Exceptions / SQL statements
► Learning Activity 12 Answer: Implicit
You have been tasked to update the database by
You can use this procedure to issue user-defined creating a PL/SQL to increase the salary of all IT
error messages from stored subprograms. Programmer employees by twice of their existing
Answer: RAISE_APPLICATION_ERROR salary. Which of the following will execute
Which of the following syntax to declare successfully?
Answer: DECLARE Answer: Procedural Language extension to SQL
v_job_id employees.job_id%TYPE := 'IT_PROG'; PL/SQL Provides a block structure for executable units
BEGIN of ________________.
UPDATE employees SET salary = salary * 2 Answer: Code
WHERE job_id = v_job_id; In PL/SQL Block Structure, which of the following are
END; mandatory?
Answer: BEGIN and END
PROG-113A / ► Week 12: Introduction to Which of the following PL/SQL will execute successfully?
PLSQL / ► Short Quiz 10 Answer: DECLARE
v_salary INTEGER(20);
Which of the folllowing is TRUE? BEGIN
Answer: SQL code are embedded withing PL/SQL
SELECT salary INTO v_salary FROM employees WHERE
statements
employee_id = 150;
In the DECLARE section of the PL/SQL block
END;
Answer: All of the choices
In PL/SQL Block Structure, which of the following Actions are being performed when error occurs during
are OPTIONAL? PL/SQL execution in the
Answer: None of the choices Answer: EXCEPTION
What are the three PL/SQL block types?
Answer: Anonymous, Procedure, Function
How do you test the output of a PL/SQL block?
PROG-113A / ► Week 11: Using Subqueries to
Answer: Use a predefined Oracle package and its
Solve Queries / ► Short Quiz 9
procedure
You want to display the name, salary and tax of
You want to display the department name the same
employee #150. Which of the PL/SQL will execute
with the location of the Purchasing department.
successfully? Note tax is computed as 2% of the
Answer: SELECT department_name from
salary.
departments where location_id = (SELECT
Answer: DECLARE
location_id from departments where
v_first_name VARCHAR2(50);
department_name = 'Purchasing')
v_last_name VARCHAR2(50);
v_salary INTEGER(20);
Evaluate the SQL command
v_tax INTEGER(10);
SELECT employee_id, job_id, salary from
BEGIN
employees where salary < ALL (SELECT salary
SELECT first_name, last_name, salary, salary *
FROM employees WHERE job_id =
0.02 INTO v_first_name, v_last_name, v_salary,
'FI_ACCOUNT') AND job_id = 'IT_PROG'
v_tax FROM employees WHERE employee_id =
Answer: This has no error.
150;
DBMS_OUTPUT.PUT_LINE('Firstname : '||
You want to display all records in the database
v_first_name);
whose salary is above the salary of Alexander
DBMS_OUTPUT.PUT_LINE('Lastname : '||
Hunold.
v_last_name);
Answer: SELECT * from employees WHERE
DBMS_OUTPUT.PUT_LINE('Salary : '|| v_salary);
salary < (SELECT salary FROM employees
DBMS_OUTPUT.PUT_LINE('Tax : '|| v_tax);
WHERE first_name = 'Alexander' AND last_name
END;
= 'Hunold')
Which of the folllowing statement describes
PL/SQL?
Evaluate the SQL command
Answer: PL/SQL is an Oracle proprietary,
SELECT employee_id, last_name, first_name,
procedural, 3GL programming language
job_id FROM employees WHERE department_id =
(SELECT max(department_id) FROM employees
PROG-113A / ► Week 12: Introduction to PLSQL / ►
GROUP BY department_id)
Learning Activity 10
PL/SQL stands for
Answer: This will return an error. Single-row Select one:
subquery returns more than one row. a. SELECT job_title FROM jobs WHERE min_salary
>= 5000 AND max_salary<= 10000
You want to display all employee id, name, hired
date and salary who are hired after employee 104 b. SELECT job_title FROM employees WHERE
salary >= 5000 AND salary <= 10000
was hired.
Answer: SELECT employee_id, last_name, c. SELECT employees_id, job_title FROM employees
hire_date, salary FROM employees WHERE WHERE salary >= 5000 AND salary <= 10000
TO_NUMBER(TO_CHAR(hire_date, 'YYYY')) > d. SELECT job_title FROM jobs WHERE salary >=
(SELECT TO_NUMBER(TO_CHAR(hire_date, 5000 AND salary <= 10000
'YYYY')) FROM employees WHERE employee_id
= 104) Question 2
Complete
Mark 2.00 out of 2.00
Flag question
Flag question
Question text
Question text
You want to display all the employee id and the month
an employee was hired. You want to display the employee's last name whose
Which SQL statement give the required output? salary is below 10,000 and whose lastname starts
with letter D.
Select one: Which SQL statement give the required output format
a. SELECT employee_id, hire_date, of the salary?
TO_DATE(hire_date,'Month') AS "Hired Month", Select one:
job_id FROM
a. SELECT last_name, TO_INT(salary, '$999,999.99')
b. SELECT employee_id, hire_date, AS "MONTHLY SALARY" FROM employees WHERE
MONTH(hire_date,'Month') AS "Hired Month", job_id salary < 10,000 WHERE last_name STARTS 'D%'
FROM employees
b. SELECT last_name, TO_CHAR(salary,
c. SELECT employee_id, hire_date, '$999,999.99') AS "MONTHLY SALARY" FROM
TO_CHAR(hire_date,'Month') AS "Hired Month", employees WHERE salary < 10000 WHERE
job_id FROM employees last_name LIKE 'D%'
d. SELECT employee_id, hire_date, c. SELECT last_name, TO_INTEGER(salary,
TO_MONTH(hire_date,'Month') AS "Hired Month", $999,999.99) AS "MONTHLY SALARY" FROM
job_id FROM employees employees WHERE salary < 10000 WHERE
last_name IN 'D%'
Question 6
Complete d. SELECT last_name, TO_NUMBER(salary,
Mark 2.00 out of 2.00
'$999,999.99') AS "MONTHLY SALARY" FROM
employees WHERE salary < 10,000 WHERE
last_name = ‘D%’
Question 8 Question 10
Complete Complete
Mark 2.00 out of 2.00 Mark 2.00 out of 2.00
Flag question
Question text
Display the first 5 letter in the surname of all the Flag question
employees whose firstname starts with letter 'N' Question text
Select one: John want to know how many employees receiving
a. SELECT SUBSTR(last_name,1,5), first_name salary below 10,000.
FROM employees WHERE first_name IN 'N' What SQL command he need to run?
Question 14
Flag question Complete
Mark 2.00 out of 2.00
Question text
Evaluate the following SQL command
SELECT employee_id, salary, department_id FROM
employees WHERE department_id IN (60,70)
Select one: Flag question
b. The SQL command will display employees with List all employees except for IT_PROG job id.
department id 60 and 70. Select one:
c. The SQL command will give an incorrect output. a. SELECT *FROM employees EXCEPT JOB_ID !=
d. The SQL command will display employees with 'IT_PROG'
department id 60 or 70. b. SELECT *FROM employees WHERE JOB_ID
NOT IN ('IT_PROG')
Question 13
Complete c. SELECT *FROM employees WHERE JOB_ID <>
Mark 2.00 out of 2.00 'IT_PROG'
d. All of the choices
Question 15
Complete
Mark 2.00 out of 2.00
Flag question
Question text
You want to display the employee's last name and
date hired in year 2000 to2006 whose salary is above
5000. Which SQL statement give the required output? Flag question
Select one: Question text
a. SELECT last_name, hire_date FROM employees Evaluate the following SQL command
WHERE hire_date>= SELECT employee_id, min_salary, max_salary
TO_DATE('01-Jan-2006', 'DD-Mon-RR') AND FROM employees, departments WHERE
hire_date<= TO_DATE('31-Dec-2006', 'DD-Mon-RR') salary>= 10000 && salary <= 20000
AND salary > 5000;
Select one:
b. SELECT last_name, hire_date FROM employees
WHERE hire_date>= a. The SQL will produce Cartesian Product
TO_DATE('Jan-2000', 'Month-YYYY') AND
hire_date<= TO_DATE('Dec-2006', 'Month-‘YYYY') b. The SQL will display the employee id, department
AND salary > 5,000; id and the minimum and maximum salary whose
salary is between 10000 and 20000.
c. SELECT last_name, hire_date FROM employees
WHERE hire_date>= c. The SQL command will produce an error.
TO_DATE('01-Jan-2000', 'DD-Mon-YYYYY') AND d. The SQL command will give an incorrect output.
hire_date<= TO_DATE('31-Dec-2006', 'DD-Mon-
YYYY') AND salary ABOVE 5000; Question 16
Complete
Mark 2.00 out of 2.00
Flag question Flag question
Question 19
Complete
Mark 2.00 out of 2.00
Flag question
Question text
Display employee's name and id whose firstname
starts with letter D and job id is IT_PROG. Flag question
Sort the output by department. Question text
Select one: Display all location id between 1000 to 2000.
a. SELECT employee_id, first_name, last_name Select one:
FROM employees ORDER BY department_id
WHERE first_name LIKE 'D%' and job_id = a. DISPLAY location_id FROM departments WHERE
'IT_PROG' location_id LING 1000 UP TO 2000
b. SELECT employees FROM employee_id, b. DISPLAY location_id FROM departments WHERE
first_name, last_name WHERE first_name LIKE ‘D%’ location_id BETWEEN 1000 TO 2000
and job_id = ‘IT_PROG’ ORDER BY department_id
c. SELECT location_id FROM departments WHERE
c. SELECT employee_id, first_name, last_name location_id IN 1000 AND 2000
FROM employees WHERE job_id = 'IT_PROG' OR
first_name LIKE 'D%' and ORDER BY department_id d. SELECT location_id FROM departments WHERE
location_id BETWEEN 1000 AND 2000
d. SELECT employee_id, first_name, last_name
FROM employees WHERE first_name LIKE 'D%' and Question 20
job_id = 'IT_PROG' ORDER BY department_id Complete
Mark 2.00 out of 2.00
Question 18
Complete
Mark 2.00 out of 2.00
Flag question Flag question
Flag question
a. SELECT E.employee_id, E.last_name, You can relate data to multiple tables using a foreign
E.first_name, D.department_name, E.salary*12 AS key.
"ANNUAL SALARY", D.location_id Select one:
FROM employees E True
NATURAL JOIN jobs J ON E.job_id = J.job_id False
NATURAL JOIN departments D ON E.department_id
= D.department_id Question 2
ORDER BY "ANNUAL SALARY" DESC Answer saved
WHERE D.location_id = 1700 AND Marked out of 1.00
D.department_name = 'Finance' Remove flag
Question 10 Question 13
Answer saved Answer saved
Marked out of 1.00 Marked out of 1.00
Flag question Flag question
You want to display the employee's last name whose You want to display the employee id and the year
salary is below 10,000 and whose lastname starts when an employee was hired.
with letter D. Which SQL statement give the required output?
Which SQL statement give the required output format Select one:
of the salary? a. SELECT employee_id, YEAR(hire_date,'YYYY')
Select one: FROM employees;
a. SELECT last_name, TO_INTEGER(salary, b. SELECT employee_id, YEAR(hire_date') FROM
$999,999.99) AS "MONTHLY SALARY" FROM employees;
employees WHERE salary < 10000 WHERE c. SELECT employee_id,
last_name IN 'D%' TO_YEAR(hire_date,'YYYY') FROM employees;
b. SELECT last_name, TO_INT(salary, '$999,999.99') d. SELECT employee_id,
AS "MONTHLY SALARY" FROM employees WHERE TO_CHAR(hire_date,'YYYY') FROM employees;
salary < 10,000 WHERE last_name STARTS 'D%'
Question 14
c. SELECT last_name, TO_CHAR(salary, Answer saved
'$999,999.99') AS "MONTHLY SALARY" FROM Marked out of 1.00
employees WHERE salary < 10000 WHERE Remove flag
last_name LIKE 'D%'
d. SELECT last_name, TO_NUMBER(salary, Question text
'$999,999.99') AS "MONTHLY SALARY" FROM Evaluate the following SQL command
employees WHERE salary < 10,000 WHERE SELECT employee_id, hire_date, department_name
last_name = ‘D%’ FROM employees, departments
WHERE departments.department_id =
Question 11
employees.department_id
Answer saved
Marked out of 1.00
Flag question
Select one:
a. The SQL command will produce an error.
Question text b. The SQL command will give an incorrect output.
c. The SQL command should have ALIAS for the
Which of the following will is the correct command to table to produce a correct output.
create a role. d. The SQL command will produce a correct output.
Select one:
Question 15
a. CREATE ROLE gen_manager Answer saved
b. None of the choices Marked out of 1.00
c. GRANT ROLE gen_manager Remove flag
Question text b. SELECT AVE(salary) FROM employees WHERE
job_id = 'IT_PROG';
Display all the records whose stock is below 20 and in c. SELECT AVG(salary) FROM employees WHERE
warehouse number 3. job_id = 'IT_PROG';
Select one: d. SELECT COUNT AVG(salary) FROM employees
a. SELECT * FROM parts WHERE onhand< 20 OR WHERE job_id = 'IT_PROG';
warehouse = 3;
Question 19
b. SELECT * FROM parts WHERE onhand> 20 OR
Answer saved
warehouse = 3; Marked out of 1.00
c. SELECT * FROM parts WHERE onhand< 20 AND Flag question
warehouse = 3;
d. SELECT * FROM parts WHERE onhand<= 20 AND Question text
warehouse = 3; A _______________ consists of a collection of DML
e. SELECT ALL FROM parts WHERE onhand< 20 statements that form a logical unit of work.
AND warehouse = 3;
f. SELECT ALL FROM parts WHERE onhand<= 20 Select one:
AND warehouse = 3; a. All of the choices
b. Transaction
Question 16 c. SQL command
Answer saved d. Database
Marked out of 1.00
Flag question
Question 20
Question text Answer saved
Marked out of 1.00
TRUE OR FALSE. Remove flag
A FOREIGN KEY is a field in one table that refers to Question text
the PRIMARY KEY in another table.
Which of the following SELECT statement is the
Select one: correct PL/SQL that will display all rows and
True columns?
False
Select one:
Question 17 a. SELECT TABLE PARTS;
Answer saved b. SELECT FROM TABLE PARTS;
Marked out of 1.00
Flag question
c. SELECT * FROM PARTS;
d. SELECT ALL FROM PARTS;
Question text
Question 21
INDEX is an example of _____________________ Answer saved
privilege. Marked out of 1.00
Remove flag
Select one:
a. System Question text
b. None of the choices Display all the records in the employee table. Arrange
c. Object the output in by lastname from A-Z order.
d. Data
Select one:
Question 18 a. SELECT * FROM employees SORT BY lastname
Answer saved b. SELECT * FROM employees ORDER BY lastname
Marked out of 1.00
Flag question
AZ
c. SELECT * FROM employees ORDER BY lastname
Question text d. SELECT * FROM employees SORT BY lastname
ascending
Ms. Ella what to generate the average salary of all
employees whose job function is IT_PROG. Question 22
Which of the following SQL command will produce the Answer saved
output. Marked out of 1.00
Flag question
Select one:
a. SELECT AVERAGE(salary) FROM employees Question text
WHERE job_id = 'IT_PROG';
Austin David was transferred to Purchasing c. SELECT salary FROM
Department. You are assigned to update the COUNT(employees)WHERE salary < 10000;
database. d. SELECT COUNT(emp_id) FROM employees
Which of the following SQL command will satisfy the WHERE salary <= 10000;
requirements?
Question 25
Select one: Answer saved
a. UPDATE first_name = ‘David’ AND last_name = Marked out of 1.00
‘Austin’ FROM employees SET department_id = 30 Flag question
b. UPDATE employees SET department_id = 30 Question text
WHERE first_name = ‘David’ AND last_name =
‘Austin’ What privileges that manipulates the content of the
c. UPDATE department_id = 30 WHERE first_name = database objects.
‘David’ AND last_name = ‘Austin’
d. UPDATE employees WHERE department_id = 30 Select one:
SET first_name = ‘David’ AND last_name = ‘Austin’ a. Object Privileges
b. Connection Privileges
Question 23 c. Network Privileges
Answer saved d. System Privileges
Marked out of 1.00
Flag question Question 26
Answer saved
Question text Marked out of 1.00
Remove flag
The General Manager request to the Database
Administrator to generate the total number of parts Question text
and total outstanding balance on hand of every class
in warehouse number 1&2. Each row of data in a table can be uniquely identified
Which of the following SQL command will generate by a
the required output. Select one:
Select one: a. foreign key
a. SELECT warehouse, class, count(partnum), b. primary key
sum(onhand) GROUP BY warehouse,class HAVING c. local key
warehouse = 1 or warehouse = 2 FROM parts; d. relational key
b. SELECT warehouse, class, count(partnum), e. index key
sum(onhand) GROUP BY warehouse,class WHERE
Question 27
warehouse = 1 or warehouse = 2 FROM parts; Answer saved
c. SELECT warehouse, class, SUM(partnum), Marked out of 1.00
SUM(onhand) FROM parts GROUP BY Flag question
warehouse,class HAVING warehouse = 1 AND
warehouse = 2; Question text
d. SELECT warehouse, class, COUNT(partnum), You want to display all the job position titles whose
SUM(onhand) FROM parts GROUP BY salary is salary from 5,000 to 12,000 arrange from
warehouse,class HAVING warehouse = 1 OR highest to lowest
warehouse = 2;
Select one:
Question 24 a. SELECT job_title FROM employees WHERE
Answer saved salary >= 5000 AND salary <= 10000
Marked out of 1.00
b. SELECT employees_id, job_title FROM employees
Flag question
WHERE salary >= 5000 AND salary <= 10000
Question text c. SELECT job_title FROM jobs WHERE salary >=
5000 AND salary <= 10000
John want to know how many employees receiving d. SELECT job_title FROM jobs WHERE min_salary
salary below 10,000. >= 5000 AND max_salary<= 10000
What SQL command he need to run?
Question 28
Select one: Answer saved
a. SELECT COUNT(salary) FROM employees Marked out of 1.00
WHERE salary < 10,000; Remove flag
b. SELECT COUNT(*) FROM employees WHERE
salary < 10000; Question text
Display all location id between 1000 to 2000. d. SELECT partnum, price, price * 1.10% FROM parts
WHERE warehouse = 3
Select one:
a. DISPLAY location_id FROM departments WHERE Question 31
location_id LING 1000 UP TO 2000 Answer saved
b. SELECT location_id FROM departments WHERE Marked out of 1.00
location_id IN 1000 AND 2000 Remove flag
c. DISPLAY location_id FROM departments WHERE Question text
location_id BETWEEN 1000 TO 2000
d. SELECT location_id FROM departments WHERE You want to display the employee's last name and
location_id BETWEEN 1000 AND 2000 date hired in year 2000 to2006 whose salary is above
5000. Which SQL statement give the required output?
Question 29
Answer saved Select one:
Marked out of 1.00 a. SELECT last_name, hire_date FROM employees
Flag question WHERE hire_date>=
Question text TO_DATE('01-Jan-2000', 'DD-Mon-YYYYY') AND
hire_date<= TO_DATE('31-Dec-2006', 'DD-Mon-
You want to display the employee's last name and YYYY') AND salary ABOVE 5000;
date hired in year 2002 whose salary is above 5000. b. SELECT last_name, hire_date FROM employees
Which SQL statement give the required output? WHERE hire_date>=
TO_DATE('01-Jan-2006', 'DD-Mon-RR') AND
Select one: hire_date<= TO_DATE('31-Dec-2006', 'DD-Mon-RR')
a. SELECT last_name, hire_date FROM employees AND salary > 5000;
WHERE hire_date >= TO_DATE('01-Jan-2000', 'DD- c. SELECT last_name, hire_date FROM employees
Mon-YYYYY') AND hire_date <= TO_DATE('31-Dec- WHERE hire_date>=
2002', 'DD-Mon-YYYY')AND salary ABOVE 5000; TO_DATE('Jan-2000', 'Month-YYYY') AND
b. SELECT last_name, hire_date FROM employees hire_date<= TO_DATE('Dec-2006', 'Month-‘YYYY')
WHERE hire_date >= TO_DATE('01-Jan-2002', 'DD- AND salary > 5,000;
Mon-RR') AND hire_date <= TO_DATE('31-Dec- d. SELECT last_name, hire_date FROM employees
2002', 'DD-Mon-RR') AND salary > 5000; WHERE hire_date>=
c. SELECT last_name, hire_date FROM employees TO_DATE('2000', 'YYYY') AND hire_date<=
WHERE hire_date >= TO_DATE('2000', 'YYYY') AND TO_DATE('2006', 'YYYY') OR salary > 5000;
hire_date <= TO_DATE('2002', 'YYYY') OR salary >
5000; Question 32
d. SELECT last_name, hire_date FROM employees Answer saved
WHERE hire_date >= TO_DATE('Jan-2000', 'Month- Marked out of 1.00
YYYY') AND hire_date <= TO_DATE('Dec-2002', Remove flag
'Month-‘YYYY') AND salary > 5,000; Question text
Question 30 Which of the following SQL commands will display all
Answer saved the stocks on hand from 10 to 30?
Marked out of 1.00
Flag question Select one:
Question text a. SELECT * FROM parts WHERE BETWEEN
onhand = 10 AND onhand = 30;
There was 10% price increase in the all the parts in b. SELECT * FROM parts WHERE onhand
warehouse number 3. The Store Manager asked the BETWEEN 10 to 30;
Database Administrator to generate a report showing c. SELECT * FROM onhand WHERE parts
the part number, the old and new price. BETWEEN onhand = 10 AND onhand = 30;
Which of the following SQL statement would satisfy d. SELECT * FROM parts WHERE onhand
the requirement of the Store Manager. BETWEEN 10 AND 30;
e. SELECT * FROM parts WHERE BETWEEN
Select one: onhand>=10 to onhand<=30;
a. SELECT partnum, price, price * 0.1 FROM parts
WHERE warehouse = 3 Question 33
b. SELECT partnum, price, price * 10% FROM parts Answer saved
WHERE warehouse = 3 Marked out of 1.00
c. SELECT partnum, price, price * 1.1 FROM parts Flag question
WHERE warehouse = 3 Question text
ANSI SQL commands cannot be abbreviated. d. SELECT department_id, MAXIMUM(salary) FROM
employees GROUP BY department_id;
Select one:
True Question 37
False Answer saved
Marked out of 1.00
Question 34 Remove flag
Answer saved
Marked out of 1.00 Question text
Remove flag
You want to display all the employee id and the month
Question text an employee was hired.
Which SQL statement give the required output?
Display the lastname of every employee in the
company. Display the output in a single column and Select one:
label it as Fullname a. SELECT employee_id, hire_date,
Format: JuanReyes TO_MONTH(hire_date,'Month') AS "Hired Month",
job_id FROM employees
Select one: b. SELECT employee_id, hire_date,
a. SELECT CONCATENATE(first_name, last_name) TO_DATE(hire_date,'Month') AS "Hired Month",
AS Fullname FROM employees job_id FROM
b. None of the choices c. SELECT employee_id, hire_date,
c. SELECT CONCAT(first_name, last_name) FROM MONTH(hire_date,'Month') AS "Hired Month", job_id
employees FROM employees
d. SELECT CONCAT(first_name, last_name) AS d. SELECT employee_id, hire_date,
Fullname FROM employees TO_CHAR(hire_date,'Month') AS "Hired Month",
job_id FROM employees
Question 35
Answer saved
Question 38
Marked out of 1.00
Remove flag Answer saved
Marked out of 1.00
Question text Flag question
Display the first 5 letter in the surname of all the Select one:
employees whose firstname starts with letter 'N' a. SELECT employee_id, hire_date,
MONTH(hire_date,'Month') AS "Hired Month",
Select one:
a. SELECT SUBSTR(last_name,1,5), first_name job_id FROM employees WHERE job_id EXCLUDE
FROM employees WHERE SUBSTR(first_name,1,1) ('AD_VP');
IN 'N' b. SELECT employee_id, hire_date,
TO_CHAR(hire_date,'Month') AS "Hired Month",
job_id FROM employees WHERE job_id NOT IN b. SELECT department_id, salary FROM employees
('AD_VP'); ORDER BY SUM(salary)
c. SELECT employee_id, hire_date, c. SELECT department_id, salary FROM employees
TO_MONTH(hire_date,'Month') AS "Hired Month", GROUP BY SUM(salary) ORDER BY department_id
job_id FROM employees WHERE job_id NOT d. SELECT department_id, TOTAL(salary) FROM
('AD_VP'); employees GROUP BY department_id
d. SELECT employee_id, hire_date,
TO_DATE(hire_date,'Month') AS "Hired Month", Question 49
job_id FROM employees WHERE job_id NOT = Answer saved
Marked out of 1.00
'AD_VP'; Flag question
Question 48
BL-PROG-3114-LAB-1922S
Answer saved PROGG(ORACLE DATABASE)
Marked out of 1.00
Flag question NCIIIP2
Question text
You want to generate the total salary per month of Dashboard
every department in the company. My courses
Select one: BL-PROG-3114-LAB-1922S
a. SELECT department_id, SUM(salary) FROM Week 3: Use of Single Row Functions
employees GROUP BY department_id Learning Activity 1
Started on Thursday, 19 December 2019, 3:21 PM
a. SELECT partnum FROM parts WHERE class
State Finished NOT IN ('HW', 'AG', SG')
Grade 6.00 out of 10.00 (60%) c. SELECT partnum FROM parts WHERE class
Question 1 NOT IN = (‘HW’, AG’, SG’)
Incorrect
d. None of the choices
Mark 0.00 out of 1.00
Question 3
Incorrect
Flag question
Question text
Question 4
a. Oracle SQL Developer; ANSI SQL Web
Correct
Select one:
Question 1
Correct
Flag question
Mark 1.00 out of 1.00
Question text
Question 2
Dashboard Correct
My courses
Mark 1.00 out of 1.00
BL-PROG-3114-LAB-1922S
c. SELECT TOTAL(last_name) FROM employees;
d. SELECT TOTALCHAR(last_name),LAST_NAME
FROM EMPLOYEES;
Flag question
Question 4
Question text
Correct
Which of the following SQL commands will Mark 1.00 out of 1.00
display all the stocks on hand from 10 to 30?
Select one:
Question text
d. SELECT first_name, last_name, salary FROM
employees WHERE department_id = 100 AND
Display the total number of characters of the last
salary < 8000 ORDER BY salary
name of all the employees.
Flag question
Question text
Flag question
Question 6
Select one:
Correct
a. SELECT * FROM parts WHERE price > 10000;
Mark 1.00 out of 1.00
Flag question
Question text
Question 9
Correct BL-PROG-3114-LAB-1922S
Mark 1.00 out of 1.00
PROGG(ORACLE DATABASE)
NCIIIP2
Dashboard
My courses
Flag question BL-PROG-3114-LAB-1922S
Week 3: Use of Single Row Functions
Question text Learning Activity 1
You can relate data to multiple tables using a Started on Thursday, 19 December 2019, 3:3
foreign key.
State Finished
Select one:
Completed on Thursday, 19 December 2019, 3:3
True
Time taken 1 min 35 secs
False Grade 6.00 out of 10.00 (60%)
b. SELECT employee_id, salary FROM employees
Question 1 WHERE salary *12 >= 100000 AND salary *12 <=
Correct 200000 ORDER BY salary
Mark 1.00 out of 1.00
c. SELECT employee_id, salary, salary *12 FROM
employees WHERE 12* salary = 100000 AND 12
*salary = 200000 ORDER BY salary
Select one:
Question text
c. SELECT * FROM PARTS;
Display the employee id and the last name of
d. SELECT TABLE PARTS; every employee in the company whose salary is
Question 2 between 5000 to 10000. Display the output in a
Correct single column with the format 100 : King Label
Mark 1.00 out of 1.00
the column as Employee
Select one:
Question text
d. SELECT RND(salary,2)/12 FROM employees;
c. SELECT DISTINCT COLUMN WAREHOUSE AS Which of the following SELECT statement is the
"No. of available warehouse" FROM PARTS; correctreport that will combine the column
PARTNUM and DESCRIPTION put a literal
d. SELECT DISTINCT WAREHOUSE AS "No. of character string "belongs to" in between the two
available warehouse" FROM PARTS; columns then rename the column as "NUMBER
Question 5 TITLE". Note put space before and after the
Correct character literal string to avoid no spaces in the
Mark 1.00 out of 1.00 report.
Select one:
Question 7
Incorrect Flag question
Display all employees id and remainder of the a. SELECT PRICE*0.10 FROM PARTS;
his/her salary after it is divided by 3,000 for all
employees with the job id of IT_PROG. b. SELECT PRICE*10, DESCRIPTION, CLASS FROM
PARTS;
Select one:
c. SELECT PRICE*0.10, DESCRIPTION, CLASS
a. SELECT employee_id, job_id, salary, salary/3000 FROM PARTS;
FROM employees WHERE job_id = 'IT_PROG'
d. SELECT PRICE*10+PRICE, DESCRIPTION, CLASS
b. SELECT employee_id, job_id, salary, FROM PARTS;
REM(salary/3000) FROM employees WHERE
job_id = 'IT_PROG' Question 9
Correct
State Finished
Select one:
f. SELECT * FROM parts WHERE partnum LIKE 'K Mark 1.00 out of 1.00
%';
ANSI SQL commands cannot be abbreviated. Which of the following SELECT statement is the
correct PL/SQL that will display eliminate the
Select one:
duplicate rows for column class and warehouse.
True Select one:
Question 5
Each row of data in a table can be uniquely Correct
identified by a
Mark 1.00 out of 1.00
Select one:
a. primary key
b. local key
Flag question
d. foreign key Display the first 5 letter in the surname of all the
employees whose firstname starts with letter 'D'
e. relational key
Select one:
Question 4
Incorrect a. SELECT SUBSTR(surname,1,5), first_name
Mark 0.00 out of 1.00 FROM employees WHERE SUBSTR(first_name,1,1)
IN 'D'
Question 8
Flag question
Correct
Question text
Mark 1.00 out of 1.00
Select one:
Flag question
a. SQL *Plus
Question text
b. SQL
Command use to display table structure
c. MySQL Plus Select one:
d. DISPLAY STRUCTURE
Question 9
Incorrect
Flag question
Mark 0.00 out of 1.00
Question text
Firstname example Santos, Arnold. Display the
output in a single column. Label the column as
Fullname
Select one:
Flag question
a. SELECT CONCAT(last_name, ',', first_name) AS
Question text
Fullname FROM employees
Which of the following is a Data Definition b. SELECT CONCAT(last_name, first_name) FROM
Language? employees
Select one:
State Finished
You want to display the employee id, date hired
Completed on of all employees whose hired date is September.
Thursday, 19 December 2019, 7:27 PM
Time taken 3 mins 9 secs Which SQL statement give the required output?
Question 1
Correct
Select one:
Flag question
Question text
You want to display the employee's last name
whose salary is below 10,000. You want to display the employee's id and
Which SQL statement give the required output formatted date hired as shown below.
format of the salary? Which SQL statement give the required output?
Required output : Required output :
Flag question
c. SELECT employee_id, hire_date,
MONTH(hire_date,'Month') AS "Hired Month", job_id Question text
FROM employees WHERE job_id EXCLUDE ('AD_VP');
What is the SQL command to display the date of
d. SELECT employee_id, hire_date, the first employee that was hired?
TO_MONTH(hire_date,'Month') AS "Hired
Month", job_id FROM employees WHERE job_id Select one:
NOT ('AD_VP');
a. SELECT FIRST(hire_date) FROM employees;
Question 6
Correct b. SELECT hire_date FROM employees WHERE
Mark 1.00 out of 1.00 FIRST(hire_date );
Question 12
a. SELECT last_name, YEAR(hire_date,'YYYY')
Correct
FROM employees WHERE job_id = ‘IT_PROG’;
Mark 1.00 out of 1.00
b. SELECT last_name, YEAR(hire_date') FROM
employees WHERE job_id = ‘IT_PROG’;
Question 15
Correct
Flag question
Mark 1.00 out of 1.00
Question text
b. 178
c. 44
State Finished
Flag question
Completed on Thursday, 19 December 2019, 7:35 P
Question text
Time taken 3 mins 55 secs
You want to display the employee’s last name whose
Grade 19.00 out of 20.00 (95%)
salary is below 10,000 and whose lastname starts with
letter K. Question 1
Correct
Which SQL statement give the required output
format of the salary? Mark 1.00 out of 1.00
Select one:
You want to display the employee id, date hired John want to know how many employees
of all employees whose hired date is September. receiving salary below 10,000. What SQL
command he need to run?
Which SQL statement give the required output?
Select one:
b. Error
c. 0 rows returned What is the SQL command to display the date of
the first employee that was hired?
d. Invalid SQL command Select one:
Question text
a. SELECT AVG(salary) FROM employees WHERE
job_id = 'IT_PROG'; John want to know how many part items are
there in warehouse number 3.
b. SELECT AVE(salary) FROM employees WHERE
job_id = 'IT_PROG'; What SQL command he need to run?
Select one:
c. SELECT AVERAGE(salary) FROM employees
WHERE job_id = 'IT_PROG'; a. SELECT partnum FROM COUNT(parts)WHERE
warehouse = 3;
d. SELECT COUNT AVG(salary) FROM employees
WHERE job_id = 'IT_PROG'; b. SELECT * FROM COUNT(parts) WHERE
Question 5
warehouse = 3;
Correct
c. SELECT COUNT(*) FROM parts WHERE
Mark 1.00 out of 1.00
warehouse = 3;
Select one:
c. SELECT warehouse, class, HIGH(price),
LOW(PRICE), SUM(onhand)
a. SELECT department_id, HIGHEST(salary) FROM
FROM parts
employees GROUP BY salary;
GROUP BY warehouse
b. SELECT department_id, MAXIMUM(salary) WHERE class = 'AP'
FROM employees GROUP BY department_id; ORDER BY warehouse, class;
Flag question
Flag question
Question text
Question text
Display the warehouse number, class, highest
price & lowest price, total on hand balance You want to display the employee id and the
whose class is AP. month an employee was hired.
Sort the output by warehouse number. Which SQL statement give the required output?
Select one: Required output :
Question 12
Correct
b. SELECT last_name, hire_date FROM employees
Mark 1.00 out of 1.00 WHERE hire_date >= TO_DATE('Jan-2000',
'Month-YYYY') AND hire_date <= TO_DATE('Dec-
2002', 'Month-‘YYYY') AND salary > 5,000;
a. 137 Question 14
Correct
c. 85
d. 44
Question text
c. SELECT warehouse, class, sum(onhand) FROM
parts GROUP BY warehouse,class HAVING Which of the following SQL command will display
SUM(ONHAND) > 50 the summary table showing the total quantity on
hand per class.
d. SELECT warehouse, class, sum(onhand) FROM
parts GROUP BY warehouseWHERE Select one:
SUM(ONHAND) > 50
a. SELECT class, TOTAL(onhand) AS "QTY ON
HAND" FROM parts GROUP BY class, onhand
Flag question
Question 4
a. DELETE * FROM departments_name HAVING Correct
department_name LIKE '%Shareholder Services%'
Mark 1.00 out of 1.00
Question text
d. DELETE FROM departments WHERE
department_name = ‘Shareholder Services’ Given the SQL command
Question 3 SELECT employees.first_name,
Correct employees.last_name,
Mark 1.00 out of 1.00
employees.salary,departments.department_name
FROM employees, departments
WHERE employees.department_id =
departments.department_id;
Which of the following describes the SQL
Flag question
command?
Add a 500 pesos increase in salary of all a. List of employees name, salary and
employees who have rendered services 10 years department name
and above.
b. Cartesian Product
Select one:
c. Results to invalid SQL command
a. UPDATE salary FROM employees SET salary +
500 where TO_YEAR(sysdate,'YYYY') - d. Results to invalid relational operator
TO_YEAR(hire_date,'YYYY') >= 10
e. Display a full outer join
b. UPDATE salary= salary + 500 where
Question 5
TO_DATE(sysdate,'YYYY') - Incorrect
TO_DATE(hire_date,'YYYY') >= 10
Mark 0.00 out of 1.00
Flag question
Question text department ON (department_id) WHERE
department_name = 'Finance'
Update the Purchasing department name to
Procurement. And this will be managed by the b. SELECT A.first_name, A.last_name, A.job_id,
Manager of Administration department. B.department_name FROM employees A JOIN
departments B ON ( A.department_id =
Select one:
B.department_id) WHERE B.department_name =
a. UPDATE FROM departments SET 'Finance'
department_name = 'Procurement' AND
c. SELECT A.first_name, A.last_name, A.job_id,
manager_id = 200 WHERE department_name =
B.department_name FROM employees A INNER
'Purchasing'
JOIN departments B ON ( A.department_id =
b. UPDATE departments SET department_name = B.department_id) ON B.department_name =
'Procurement', manager_id = 200 WHERE 'Finance'
department_name = 'Purchasing'
d. All of the choices
c. UPDATE * FROM departments SET Question 7
department_name = 'Procurement', SET Correct
manager_id = 200 HAVING department_name =
Mark 1.00 out of 1.00
'Purchasing'
c. INSERT INTO jobs VALUES ('JAVA_DEV', 'Java Update the Treasury department to Cash
Developer', 7000, 8000) department. And this will be managed by the
Manager of Finance department.
d. INSERT FROM jobs(jobs_id, job_title, Select one:
min_salary, max_salary) VALUES ('JAVA_DEV',
'Java Developer', 7000, 8000) a. UPDATE FROM departments SET
department_name = 'Procurement', SET
Question 9
Correct manager_id = 100 HAVING department_name =
'Treasury'
Mark 1.00 out of 1.00
Flag question
Question text
c. UPDATE department_name = 'Procurement' a. INSERT FROM jobs SET jobs_id = ‘JAVA_DEV’,
AND manager_id = 100FROM departments job_title = ‘Java Developer’ , min_salary =7000 ,
WHERE department_name = 'Treasury' max_salary= 8000
d. UPDATE departments SET department_name = b. INSERT * INTO jobs VALUES (JAVA_DEV, Java
'Procurement', manager_id = 100 WHERE Developer, 7000, 8000)
department_name = 'Treasury'
c. INSERT INTO jobs VALUES ('JAVA_DEV', 'Java
Developer', 7000, 8000)
BL-PROG-3114-LAB-1922S
PROGG(ORACLE DATABASE) d. INSERT FROM jobs(jobs_id, job_title,
min_salary, max_salary) VALUES ('JAVA_DEV',
NCIIIP2
'Java Developer', 7000, 8000)
Question 2
Dashboard Correct
My courses
BL-PROG-3114-LAB-1922S Mark 1.00 out of 1.00
Week 7: Manipulate Data
Learning Activity 2
Question text
b. INSERT INTO departments SET department_id
= 300, department_name = 'Training',
Create a SQL command to add a new position
manager_id = 203, location_id = 2400
Java Developer with job id of JAVA_DEV whose
salary ranges from 7,000 to 8,000.
c. INSERT FROM departments(department_id,
Select one: department_name, manager_id, location_id)
VALUES (300, 'Training', 203, 2400)
d. INSERT INTO departments VALUES (300, Given the SQL command
'Training', 203, 2400) SELECT employees.first_name,
employees.last_name,
Question 3 employees.salary,departments.department_name
Correct
FROM employees, departments
Mark 1.00 out of 1.00 WHERE employees.department_id =
departments.department_id;
Which of the following describes the SQL
command?
Select one:
Flag question
Question text
Mark 1.00 out of 1.00
c. DELETE departments FROM
departments_name WHERE department_name =
‘%Shareholder Services%’
c. SELECT employees.first_name,
employees.last_name, employees.salary FROM
employees CROSS JOIN departments USING
(department_id) WHERE employees.salary >=
5000 AND employees.salary <= 10000
Question 10
Correct