0% found this document useful (0 votes)
133 views6 pages

SQL Exam Questoins

The document contains 15 multiple choice questions about SQL concepts and syntax. The questions cover topics like describing table structures, DML statements, aggregate functions, joins, subqueries and more.

Uploaded by

vamsi krishna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views6 pages

SQL Exam Questoins

The document contains 15 multiple choice questions about SQL concepts and syntax. The questions cover topics like describing table structures, DML statements, aggregate functions, joins, subqueries and more.

Uploaded by

vamsi krishna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

Review the following output from a SQL*Plus session:


Name Null? Type
-------- -------- ------------
SYMPTOM NOT NULL VARCHAR2(10)
CAUSE VARCHAR2(10)
TREATMENT VARCHAR2(9)

Which of the following keywords likely produced the output above?

A .get
B . run
C. describe
D . spool

2. Which are DML statements? (Choose all that apply)

A. COMMIT...
B. MERGE...
C. UPDATE...
D. DELETE...
E. CREATE...
F. DROP...

3. Examine the structure of the EMPLOYEES table:

EMPLOYEE_ID NUMBER Primary Key


FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
Which three statements insert a row into the table? (Choose three.)

A. INSERT INTO employees VALUES (NULL.'John','Smith');


B. INSERT INTO employees (first_name, last_name) VALUES ('John', 'Smith');
C.INSERT INTO employees VALUES (1000, 'John', 'Smith');
E.INSERT INTO employees (employee_id) VALUES (1000);
F.INSERT INTO emloyees (employee_id_first_name,last_name) VALUES (1000,'John', 'Smith');

4. Examine the description of the EMPLOYEES table:

EMP_ID NUMBER(4) NOT NULL


LAST_NAME VARCHAR2(30) NOT NULL
FIRST_NAME VARCHAR2(30)
DEPT_ID NUMBER(2)
JOB_CAT VARCHAR2(30)
SALARY NUMBER(8,2)

Which statement shows the maximum salary paid in each job category of each department?

A. SELECT dept_id, job_cat, MAX (salary) FROM employees WHERE salary > MAX (salary);
B. SELECT dept_id, job_cat, MAX (salary) FROM employees GROUP BY dept_id, job_cat
C. SELECT dept_id, job_cat, MAX(salary) FROM employees;
D. SELECT dept_id, job_cat, MAX (salary) FROM employees GROUP BY dept_id;
E. SELECT dept_id, job_cat, MAX (salary) FROM employees GROUP BY dept_id, job_cat, salary

5.Examine the description of the STUDENTS table:


STD_ID NUMBER(4)
COURSE_ID VARCHAR2(10)
START_DATE DATE
END_DATE DATE
Which two aggregate functions are valid on the START_DATE column? (Choose Two)
A. SUM(start_date)
B. AVG (start_date)
C. COUNT (start_date)
D. AVG(start_date, end_date)
E. MIN (start_date)
F. MAXIMUM (start_date)

6. Examine the data from the EMP table.

EMP_ID DEPT_ID COMMISSION


1 10 500
2 20 1000
3 10
4 10 600
5 30 800
6 30 200
7 10
8 20 300
The COMMISSION column shows the monthly commission earned by the employee.
Which three tasks would require subqueries or joins in order to be performed in a single step? (Choose
three)

A. deleting the records of employees who do not earn commission


B. increasing the commission of employee 3 by the average commission earned in department 20
C. finding the number of employees who do NOT earn commission and are working for department 20
D. inserting into the table a new employee 10 who works for deartment 20 and earns a commission that
is equal to the commission earned by employee 3
E. creating a table called COMMISSION that has the same structure and data as the columns EMP_ID
and COMMISSION of the EMP table
F. decreasing the commission by 150 for the employees who are working in department 30 and earning
a commission of more than 800.

7. Evaluate the SQL statement:

1 SELECT a.emp_name, a.sal, a.dept_id, b.maxsal


2 FROM employees a,
3 (SELECT dept_id, MAX(sal) maxsal
4 FROM employees
5 GROUP BY dept_id)b
6 WHERE a.dept_id = b.dept_id
7 AND a.sal<b.maxsal;

What is the result of the statement?

A. The statement produces an error at line1.


B. The statement produces an error at line3.
C. The statement produces an error at line6.
D. The statement returns the employee name, salary, department ID, and maximum salary earned in the
department of the employee for all departments that pay less salary than the maximm salary aid in the
company.
E. The statement returns the employee name, salary, department ID, and maximum salary earned in the
department of the employee for all employees who earn less than the maximum salary in their
department.

8. Examine the structure of the EMPLOYEES and DEPARTMENTS tables:


EMPLOYEES
Column name Data Type Remarks
EMPLOYEE_ID NUMBER NOT NULL, PRIMARY KEY
EMP_NAME VARCHAR2(30)
JOB_ID VARCHAR2(20)
SALARY NUMBER
MGR_ID NUMBER References employee ID column
DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of the
DEPARTMENT table

DEPARTMENTS
Column name Data Type Remarks
DEPARTMENT_ID NUMBER NOT NULL, Primary key
DEPARTMENT_NAME VARCHAR2(30)
MGR_ID NUMBER References MGR_ID column of the EMPLOYEES table

Evaluate this SQL statement;

SELECT employee_id, e.department_id, department_name, salary


FROM employees e, departments d WHERE e. department_id=d.department_id;

Which SQL statement is equivalent to the above SQL statement?

A. SELECT employee_id, department_id, department_name, salary FROM employees


WHERE department_id IN (SELECT department_id FROM departments);
B. SELECT employee_id, department_id, department_name, salary
FROM employees NATURAL JOIN departments d ON e.department_id=d.department_id;
C. SELECT employee_id, department_id, department_name, salary
FROM employees e JOIN departments d ON e.department_id=d.department_id;
D. SELECT employee_id, department_id, department_name, salary
FROM employees JOIN departments USING (e.department_id, d.department_id);

10. Which operator can be used with a multiple row subquery?


A. **
B. LIKE
C. BETWEEN
D. NOT IN
E. Is
F. <>

11.Examine the structure of the EMPLOYEES and NEW EMPLOYEES tables:

EMPLOYEE_ID NUMBER Primary Key


FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE

NEW EMPLYEES
EMPLOYEE_ID NUMBER Primary Key
NAME VARCHAR2(60)

Which MERGE statement is valid?

A. MERGE INTO new_employees e USING employees e


ON (e.employee_id = e.employee_id) WHEN MATCHED THEN
UPDATE SET e.name = e.first_name //’,’// e.last_name
WHEN NOT MATCHED THEN INSERT VALUES (e.employee_id, e.first_name//’,
‘//e.last_name);
B. MERGE new_employee c USING employees e ON (c.employee_id = e.employee_id)
WHEN EXISTS THEN UPDATE SET c.name = e first_name//’,’// e.last_name
WHEN NOT MATCHED THEN INSERT VALUES (e.employee_id, e.first_name//’.
‘//e.last_name);
C. MERGE INTO new employees c USING employees e
ON (c.employee_id = e.employee_id) WHEN EXISTS THEN
UPDATE SET e.name = e.fist //’,’// e.last_name
WHEN NOT MATCHES THEN INSERT VALUES (e.employee_id, e.first _name//’,
‘//e.last_name);
D. MERGE new_employees c FROM employees c ON (c.employee_id = e.employee_id) WHEN
MATCHED THEN UPDATE SET e.name = e.first_name //’,’// e.last_name
WHEN NOT MATCHED THEN INSERT INTO new_employees VALUES (e.employee_id,
e.first_name//”. ‘//e.last_name);

12. Which SELECT statement should you use to extract the year form the system date and display it in
the format “1998”?

A. SELECT TO_CHAR(SYSDATE, ‘yyyy’) FROM dual


B. SELECT TO_DATE(SYSDATE,’yyyy’) FROM dual
C. SELECT DECODE (SUBSTR (SYSDATE, 8), ‘YYYY’) FROM dual
D. SELECT DECODE (SUBSTR (SYSATE, 8),’year’) FROM dual
E. SELECT TO_CHAR (SUBSTR(SYSDATE, 8,2),’yyyy’) FROM dual

13.Examine the data in the DEPARTMENTS table.

DEPARTMENTS
DEPARTMENT_ID DEPARTMENT_NAME
10 Sales
20 Marketing
30 Accounts

Write a query, which displays following output.

14. Examine the data in the EMPLOYEES and DEPARTMENTS tables.

EMPLOYEES
LAST_NAME DEPARTMENT_ID SALARY
Get z 10 3000
Davis 10 1500
King 10 2200

DEPARTMENTS
DEPARTMENT_ID DEPARTMENT_NAME
10 Sales
10 Marketing
10 Accounts

Write the output for following query.

15. Examine the data from the ORDERS and CUSTOMERS tables.
ORDERS
ORD_ID ORD_DATE CUST_ID ORD_TOTAL
100 12.JAN.2000 15 10000
101 09.MAR.2000 40 8000
102 09.MAR.2000 35 12500
103 15.MAR.2000 15 12000
104 25.JUN.2000 15 6000
105 18.JUL.2000 20 5000
106 18.JUL.2000 35 7000
107 21.JUL.2000 20 6500
108 04.AUG.2000 10 8000
CUSTOMERS
CUST_ID CUST_NAME CITY
10 Smith Los Angeles
15 Bob San Francisco
20 Martin Chicago
25 Mary New York
30 Rina Chicago
35 Smith New York
40 Linda New York

Write SQL statement retrieves the order ID, order date, customer name and, order total along with
maximum order total placed in the same day.

You might also like