0% found this document useful (0 votes)
85 views5 pages

Knowledge Check 7 Solution

The document contains solutions to 10 knowledge check questions about SQL statements. Question 1 asks about ordering query results by column name or number and the answer is that both methods will produce identical results. Question 2 asks about using an alias in a column select and the answer is that the alias name will be used as the column heading rather than the original column name. Question 3 asks about removing parentheses from a formula in a select statement and the answer is that it will not change the results.

Uploaded by

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

Knowledge Check 7 Solution

The document contains solutions to 10 knowledge check questions about SQL statements. Question 1 asks about ordering query results by column name or number and the answer is that both methods will produce identical results. Question 2 asks about using an alias in a column select and the answer is that the alias name will be used as the column heading rather than the original column name. Question 3 asks about removing parentheses from a formula in a select statement and the answer is that it will not change the results.

Uploaded by

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

Knowledge Check 7a – Solution

1) What is the output of the following SQL Statement

SELECT empname, empsal from employee ORDER BY empsal desc;


SELECT empname,empsal from employee ORDER BY 2 desc;

a) Both will produce identical results


b) Second statement will give an error
c) Second statement will not give any result
d) Both will produce results, but both will be different.

Feedback:

A) Correct. We can order the results according to the column name or


according to a column standing position..

B) Incorrect. A is the correct answer.

C) Incorrect. A is the correct answer.

D) Incorrect. A is the correct answer

2) SELECT empname ename from employee;

What is the resulting column heading


a) empname
b) ename
c) empname ename
d) None of the above

Feedback:

A) Incorrect B is the correct answer

B) correct. If we use an alias the result will display the alias name instead of the
original column name.

C) Incorrect. B is the correct answer.

D) Incorrect. B is the correct answer.


3) Evaluate the following SQL Statement:

SELECT e.employee_id, (0.15 *salary) + (0.5 * e.commission_pct)


+ (s.sales_amount) * (.35 * e.bonus)) CALC_VALUE
FROM employees e, sales s
Where e.employee_id = s.emp_id;

What happens if parentheses is removed from the formula (choose the correct
option)

A. The Value displayed in the CALC_VALUE column will be lower.


B. The value displayed in the CALC_VALUE column will be higher.
C. There will be no difference in the value displayed in the
CALC_VALUE column.
D. An error will be reported.

Feedback:

A) Incorrect. C is the correct answer.

B) Incorrect. C is the correct answer.

C) correct. There will not be any difference in the value displayed in the
CALC_VALUE column..

D) Incorrect. C is the correct answer.

4) Add a PHONE_NUMBER column of NUMBER data type to an existing


EMPLOYEES table. The EMPLOYEES table already contains records of 100
employees.
Which of the following command do you use to add phone numbers to all the 100
records
A. INSERT
B. UPDATE
C. ADD
D. ENTER

Feedback:

A) Incorrect B is the correct answer.

B) correct. B is the correct answer.


C) Incorrect. B is the correct answer.

D) Incorrect .B is the correct answer.

5) The EMP table contains these columns:

LAST_NAME VARHCAR2(25),
SALARY NUMBER (6,2),
DEPARTMENT_ID NUMBER(6)

Write a SQL statement to display the employees who have not been assigned to
any department.

6) The EMP table has these columns:

ENAME VARCHAR2(35)
SALARY NUMBER(8,2),
HIRE_DATE DATE

Management wants a list of names of employees who have been with the
company for more than five years. Which SQL Statement displays the desired
results?

A. SELECT ENAME FROM EMP WHERE SYSDATE – HIRE_DATE > 5;


B. SELECT ENAME FROM EMP WHERE HIRE_DATE – SYSDATE > 5;
C. SELECT ENAME FROM EMP WHERE (SYSDATE – HIRE_DATE) /365 >
5;
D. SELECT ENAME FROM EMP WHERE (SYSDATE * HIRE_DATE) * 365 > 5;

Feedback:

A) Incorrect. C is the correct answer. The left hand side of the WHERE clause
will give only the number of days between the two dates.

B) Incorrect. C is the correct answer. This will produce negative value.

C) Correct. The difference between two dates will result in number of days
elapsed. If you divide it by 365 you will get number of years.

D) Incorrect. C is the correct answer.


7. __________are the Wildcards Used for Single Character and Multi Character
pattern matching

A. _ and %;
B. % and _ ;
C. * and _
D. _ and *

Feedback:

A) Correct.

B) Incorrect.

C) Incorrect.

D) Incorrect.

8. The (*) asterisk in select statement is to specify ___________

A. All Columns from a table


B. All Rows from a table
C. None of the above

Feedback:

A) Correct.

B) Incorrect.

C) Incorrect.

9. ________ key with WHERE clause specifies an inclusive range to search

A. IN
B. BETWEEN
C. LIKE
D. NULL

Feedback:

A) InCorrect.

B) Correct.
C) Incorrect.

D) Incorrect

10. ________ key in the where clause specifies an inclusive list to search

A. IN
B. BETWEEN
C. LIKE
D. NULL

Feedback:

A) Correct.

B) InCorrect.

C) Incorrect.

D) Incorrect

You might also like