Shiridi Sai Baba

Retrieving Data Using the SQL SELECT Statement - Answers

          1.   Find the following Operations :
(i)  Restricting the columns from a table ?
(ii) Restricting the columns from a table ?
(iii) Interacting tables with each other ?

A.  PROJECTION, SELECTION, JOINING
B.    SELECTION, PROJECTION, JOINING
C.   PROJECTION, UNKNOWN, JOINING
D.   NONE OF THE ABOVE.

2.   When querying the JOBS table for every row containing just the JOB_ID and MAX_SALARY
Columns which operation is performed ?

A.  PROJECTION
B.    SELECTION
C.   JOINING
D.   None of the Above

3.   Which of the following Queries doesn’t return any error ?
(i)            select empno as 'Employee Number' from emp;
(ii)          select empno as Employee Number from emp;
(iii)      select empno as "Employee Number" from emp;
(iv)         select empno as ‘EmployeeNumber’ from emp;

4.    Which query creates a projection of the DEPARTMENT_NAME and LOCATION_ID columns from the DEPARTMENTS table?
      (Choose the best answer.)

A. SELECT DISTINCT DEPARTMENT_NAME, LOCATION_ID FROM DEPARTMENTS;
B. SELECT DEPARTMENT_NAME, LOCATION_ID FROM DEPARTMENTS;
C. SELECT DEPT_NAME, LOC_ID FROM DEPT;
D. SELECT DEPARTMENT_NAME AS “LOCATION_ID” FROM DEPARTMENTS;

5.   After describing the EMPLOYEES table, you discover that the SALARY column has a datatype of NUMBER(8,2). Which SALARY value(s) will not be permitted in this column?
      (Choose all that apply.)

A. SALARY=12345678
B. SALARY=123456.78
C. SALARY=12345.678
D. SALARY=123456
E. SALARY=12.34

6.   After describing the JOB_HISTORY table, you discover that the START_DATE and END_DATE columns have a datatype of DATE.
      Consider the expression END_DATE-START_DATE.
      (Choose two correct statements.)

A. A value of DATE data type is returned.
B. A value of type NUMBER is returned.
C. A value of type VARCHAR2 is returned.
D. The expression is invalid since arithmetic cannot be performed on columns with DATE
data types.
E. The expression represents the days between the END_DATE and START_DATE.

7.   The DEPARTMENTS table contains a DEPARTMENT_NAME column with datatype VARCHAR2(30).
      (Choose two true statements about this column.)

A. This column can store character data up to a maximum of 30 characters.
B. This column must store character data that is at least 30 characters long.
C. The VARCHAR2 data type is replaced by the CHAR data type.
D. This column can store data in a column with datatype VARCHAR2(50) provided that the  
contents are at most 30 characters long.

8.   Which statement reports on unique JOB_ID values from the EMPLOYEES table?
      (Choose all that apply.)

A. SELECT JOB_ID FROM EMPLOYEES;
B. SELECT UNIQUE JOB_ID FROM EMPLOYEES;
C. SELECT DISTINCT JOB_ID, EMPLOYEE_ID FROM EMPLOYEES;
D. SELECT DISTINCT JOB_ID FROM EMPLOYEES;

9.   Choose the two illegal statements. The two correct statements produce identical results.

A.  SELECT DEPARTMENT_ID|| ' represents the '|| DEPARTMENT_NAME||' Department' as
"Department Info" FROM DEPARTMENTS;
B.    SELECT DEPARTMENT_ID|| ' represents the || DEPARTMENT_NAME||' Department' as
"Department Info" FROM DEPARTMENTS;
C.  select department_id|| ' represents the '||department_name||' Department'
"DepartmentInfo" from departments;
D.   SELECT DEPARTMENT_ID represents the DEPARTMENT_NAME Department as
"Department Info" FROM DEPARTMENTS;


10.         Which expressions do not return NULL values? (Choose all that apply.)

A. select ((10 + 20) * 50) + null from dual;
B. select 'this is a '||null||'test with nulls' from dual;
C. select null/0 from dual;
D. select null||'test'||null as “Test” from dual;
    
11.        Choose the correct syntax to return all columns and rows of data from the EMPLOYEES table.

A. select all from employees;
B. select employee_id, first_name, last_name, first_name, department_id from employees;
C. select % from employees;
D. select * from employees;
E. select *.* from employees;

12.         The following character literal expression is selected from the DUAL table:
SELECT 'Coda''s favorite fetch toy is his orange ring' FROM DUAL;
(Choose the result that is returned.)
A. An error would be returned due to the presence of two adjacent quotes
B. Coda's favorite fetch toy is his orange ring
C. Coda''s favorite fetch toy is his orange ring
D. 'Coda''s favorite fetch toy is his orange ring'


13. There are four rows of data in the REGIONS table. Consider the following SQL statement:
SELECT '6 * 6' “Area” FROM REGIONS;
How many rows of results are returned and what value is returned by the Area column?
(Choose the best answer.)
A. 1 row returned, Area column contains value 36
B. 4 rows returned, Area column contains value 36 for all 4 rows
C. 1 row returned, Area column contains value 6 * 6
D. 4 rows returned, Area column contains value 6 * 6 for all 4 rows
E. A syntax error is returned