Practice exam questions

The following practice exam questions test your knowledge of material that this chapter covers.

1:Which statement is true?
  1. The CHAR scalar function returns a string representation of the input value.

  2. The DECIMAL scalar function returns a decimal representation of the input value.

  3. The YEAR scalar function produces a single scalar value for each table row that satisfies the search condition.

  4. All of the above are true.

2:Which result table below could be generated by the following SQL statement?
SELECT EMPNO, (SALARY + COMM)
 FROM EMP;

  1. EMPNO      SALARY      COMM
    ======     ========    =======     ========
    000010     52750.00    4220.00     56970.00
    000020     41250.00    3300.00     44550.00
    000030     38250.00    3060.00     41310.00
    000060     32250.00    2500.00     34830.00
    
  2. EMPNO
    ======     ========
    000010     56970.00
    000020     44550.00
    000030     41310.00
    000060     34830.00
    
  3. EMPNO      SALARY      COMM        SALARY + COMM
    ======     =========   =======     =============
    000010     52750.00    4220.00     56970.00
    000020     41250.00    3300.00     44550.00
    000030     38250.00    3060.00     41310.00
    000060     32250.00    2500.00     34830.00
    
  4. EMPNO     SALARY + COMM
    ======    =============
    000010    56970.00
    000020    44550.00
    000030    41310.00
    000060    34830.00
    
3:A programmer wants to add the content of all the rows in a numeric column named SALARY. Which SQL aggregate function (not fully executable) could the programmer use?
  1. ADD(SALARY)

  2. SUM(SALARY)

  3. SALARY(ADD)

  4. SALARY(SUM)

4:Which result table below could be generated by the following SQL statement?
SELECT EMPNO, SALARY + COMM AS TOTAL_SAL
 FROM EMP
 ORDER BY TOTAL_SAL;

  1. EMPNO     SALARY      COMM        TOTAL_SAL
    ======    =========   =======     =========
    000060    32250.00    2500.00     34830.00
    000030    38250.00    3060.00     41310.00
    000020    41250.00    3300.00     44550.00
    000010    52750.00    4220.00     56970.00
    
  2. EMPNO     SALARY      COMM        SALARY + COMM
    ======    =========   =======     =============
    000060    32250.00    2500.00     34830.00
    000030    38250.00    3060.00     41310.00
    000020    41250.00    3300.00     44550.00
    000010    52750.00    4220.00     56970.00
    
  3. EMPNO     TOTAL_SAL
    ======    =========
    000060    34830.00
    000030    41310.00
    000020    44550.00
    000010    56970.00
    
  4. EMPNO     TOTAL_SAL
    ======    =========
    000010    56970.00
    000020    44550.00
    000030    41310.00
    000060    34830.00
    
5:To calculate the average earnings of all employees who have a commission greater than 0, which statement could a programmer use?
  1. SELECT AVERAGE(SALARY+NULLIF)(COMM,0))
     FROM EMP;
    
  2. SELECT AVERAGE(SALARY)+NULLIF(COMM,0)
     FROM EMP;
    
  3. SELECT AVG(SALARY+NULLIF(COMM>0))
     FROM EMP;
    
  4. SELECT AVG(SALARY+NULLIF(COMM,0))
     FROM EMP;
    
6:Which of the items below is not a DB2 scalar function?
  1. YEAR

  2. CHAR

  3. NULLIF

  4. None of the above; all are scalar functions.

7:Which SQL statement with a CASE expression is valid?
  1. SELECT EMPNO, LASTNAME,
    CASE
     WHEN EDL<=12 THEN 'HIGH SCHOOL OR LESS'
    END
    AS EDUCATION
    FROM EMP;
    
  2. SELECT EMPNO, LASTNAME,
    CASE
     WHEN EDL<=12 THEN 'HIGH SCHOOL OR LESS'
    AS EDUCATION
    FROM EMP;
    
  3. SELECT EMPNO, LASTNAME,
    CASE
     WHEN EDL<=12 THEN 'HIGH SCHOOL OR LESS' AS EDUCATION
    END
    FROM EMP;
    
  4. SELECT EMPNO, LASTNAME,
    CASE
     WHEN EDL<=12 THEN 'HIGH SCHOOL OR LESS'
    ENDCASE
    AS EDUCATION
    FROM EMP;
    
8:Which statement is false?
  1. A WHERE clause can be used to indicate which rows of data to access.

  2. A WHERE clause specifies a search condition.

  3. The search condition of a WHERE clause includes one or more predicates that are combined through the use of logical operators AND, OR, and NOT.

  4. None of the above; all statements are true.

9:To select the rows that contain a null value in the MIDINIT (middle initial) column, which WHERE clause could a programmer use?
  1. WHERE MIDINIT = NULL

  2. WHERE MIDINIT IS NULL

  3. WHERE MIDINIT IS ' '

  4. None of the above.

10:Which pair of WHERE clauses are not equivalent?
  1. WHERE NOT DEPTNO < 'A00' and WHERE DEPTNO >= 'A00'

  2. WHERE NOT DEPTNO >= 'A00' and WHERE DEPTNO < 'A00'

  3. WHERE DEPTNO = 'A00' and WHERE NOT DEPTNO <> 'A00'

  4. None of the above; all pairs are equivalent.

11:Which WHERE clause is not a valid equivalent to the others?
  1. WHERE DEPTNO = ('B01', 'C01', 'D11')

  2. WHERE DEPTNO IN ('B01', 'C01', 'D11')

  3. WHERE DEPTNO = 'B01' OR DEPTNO = 'C01' OR DEPTNO = 'D11'

  4. None of the above; all are valid and equivalent.

12:Which statement about the ORDER BY clause is false?
  1. Using the ORDER BY clause is the only way to guarantee that your rows are in the sequence in which you want them.

  2. The order of the selected rows depends on the column that you identify in the ORDER BY column.

  3. Null values appear first in an ascending sort and last in a descending sort.

  4. To retrieve the results in ascending order, specify or use the default of ASC.

13:Which statement-and-result pair reflects a pair that will work as shown?
  1. SELECT JOB, EDL, LASTNAME
     FROM EMP
     WHERE DEPT = 'A00'
     ORDER BY EDL, JOB;
    
    JOB        EDL   LASTNAME
    ===        ===   ========
    PRES       18    HAAS
    SLS        14    CONNOR
    SLS        18    HEMMINGER
    
  2. SELECT JOB, EDL, LASTNAME
     FROM EMP
     WHERE DEPT = 'A00'
     ORDER BY JOB, EDL;
    
    JOB        EDL   LASTNAME
    ===        ===   ========
    PRES       18    HAAS
    SLS        18    HEMMINGER
    SLS        14    CONNER
    
  3. SELECT JOB, EDL, LASTNAME
      FROM EMP
      WHERE DEPT = 'A00'
      ORDER BY JOB, EDL;
    
    JOB        EDL   LASTNAME
    ===        ===   ========
    PRES       18    HAAS
    SLS        14    CONNER
    SLS        18    HEMMINGER
    
  4. SELECT JOB, EDL, LASTNAME
     FROM EMP
     WHERE DEPT = 'A00'
     ORDER BY LASTNAME, EDL;
    
    JOB        EDL   LASTNAME
    ===        ===   ========
    SLS        14    CONNOR
    SLS        18    HEMMINGER
    PRES       18    HAAS
    
14:Which statement about joins is false?
  1. The main ingredient of a join is typically matching column values in rows of each table that participates in the join.

  2. A join is specified in the WHERE clause of a query.

  3. A joined table specifies an intermediate result table that is the result of either an inner join or an outer join.

  4. The result of a join associates rows from one table with rows from another table.

15:Which statement is true?
  1. An inner join combines the rows that are produced by the outer join, plus the missing rows, depending on the type of inner join.

  2. There are two types of inner join: a left inner join and a right inner join.

  3. A full outer join includes the rows from both tables that were missing from the inner join.

  4. An outer join combines each row of the left table with each row of the right table, keeping only the rows in which the join condition is true.

16:Which type of join could a programmer use to combine each row of the left table with each row of the right table, keeping only the rows in which the join condition is true?
  1. Inner join

  2. Left outer join

  3. Left inner join

  4. Full outer join

17:Which statement is false?
  1. A subquery is helpful when you need to narrow your search condition that is based on information in an interim table.

  2. The COALESCE function is particularly helpful in full outer join operations because it returns the first nonnull value.

  3. The join condition of a right outer join can be any simple or compound search condition that contains a subquery reference.

  4. None of the above; all statements are true.

18:Which statement is false?
  1. SQL statements can be used to insert, update, or delete data.

  2. DB2 ensures that an insert, update, or delete operation does not violate any referential constraints or check constraints that are defined on the table.

  3. The INSERT statement or LOAD utility can be used to add new data to an existing table.

  4. The SQL INSERT statement can be used to add rows to a table, but not to a view.

19:Which SQL statement is valid?
  1. INSERT INTO NEWDEPT (DEPTNO, DEPTNAME, MGRNO, ADMRDEPT)
     VALUES (E31, PUBLISHING, 000020, D11);
    
  2. INSERT IN NEWDEPT (DEPTNO, DEPTNAME, MGRNO, ADMRDEPT)
     VALUES ('E31', 'PUBLISHING', '000020', 'D11'),
    
  3. INSERT INTO NEWDEPT (DEPTNO, DEPTNAME, MGRNO, ADMRDEPT)
    VALUES ('E31', 'PUBLISHING', '000020', 'D11'),
    
  4. INSERT VALUES ('E31', 'PUBLISHING', '000020', 'D11')
     INTO NEWDEPT (DEPTNO, DEPTNAME, MGRNO, ADMRDEPT);
    
20:Which task cannot be done with an SQL INSERT statement?
  1. Include a SELECT statement in the INSERT statement to tell DB2 that another table contains the data for the new row or rows.

  2. Use host variable arrays in the VALUES clause of the INSERT FOR n ROWS statement to insert multiple rows into a table.

  3. Specify the values to insert in a single row.

  4. None of the above; SQL INSERT statements can be used for the tasks in options A, B, and C.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.204.201