Datasheet

Answers to Review Questions
61
Answers to Review Questions
1. C. Column alias names enclosed in quotation marks will appear as typed. Spaces and
mixed case appear in the column alias name only when the alias is enclosed in double quo-
tation marks.
2. A. Statements 1 and 2 will produce the same result. You can use the column name, column
alias, or column position in the ORDER BY clause. The default sort order is ascending. For a
descending sort, you must explicitly specify that order with the DESC keyword.
3. B. In the arithmetic evaluation, multiplication and division have precedence over addition
and subtraction. Even if you do not include the parentheses, salary*0.1 will be evaluated
first. The result is then divided by 2, and its result is added to 200.
4. A, C. Character literals in the SQL statement are enclosed in single quotation marks. Liter-
als are concatenated using ||. Employee Name: is a character literal, and 10 is a numeric
literal.
5. B. Since the numeric column is defined with precision 7 and scale 2, you can have five dig-
its in the integer part and two digits after the decimal point. The digits after the decimal are
rounded.
6. B. The default display format of DATE column is DD-MON-YY, whose length is 9.
7. D. DISTINCT is used to display a unique result row, and it should follow immediately after
the keyword SELECT. Uniqueness is identified across the row, not a single column.
8. B. The WHERE clause is used to limit the rows returned from a query. The WHERE clause con-
dition is evaluated, and rows are returned only if the result is TRUE. The ORDER BY clause is
used to display the result in certain order.
9. B. There are three records belonging to DEPTNO 10: EMPNO 7934 (MILLER), 7839 (KING),
and 7782 (CLARK). When you sort their names by descending order, MILLER is the first row
to display. You can use alias names and columns that are not in the SELECT clause in the
ORDER BY clause.
10. D. Here, a character column is compared against a string using the BETWEEN operator,
which is equivalent to ename >= ‘A’ AND ename <= ‘C’. The name CLARK will not be
included in this query, because ‘CLARK’ is > ‘C’.
11. C. Column alias names cannot be used in the WHERE clause. They can be used in the ORDER
BY clause.
12. A. The IN operator can be used. You can write the WHERE clause as WHERE empno IN
(7782, 7876);.
13. B. The FROM clause appears after the SELECT statement, followed by WHERE and ORDER BY
clauses. The FROM clause specifies the table names, the WHERE clause limits the result set,
and the ORDER BY clause sorts the result.
95127c01.indd 61 2/18/09 6:37:12 AM