Answers






Answers

5.1

  1. Correct; float data type.

  2. Incorrect; there must be quotation marks in front of and after the alphanumeric literal.

  3. Correct; alphanumeric data type.

  4. Incorrect; there are characters outside the quotation marks of the alphanumeric literal.

  5. Correct; alphanumeric data type.

  6. Correct; integer data type.

  7. Correct; alphanumeric data type.

  8. Correct; alphanumeric data type.

  9. Correct; date data type.

  10. If it is supposed to be an alphanumeric literal, it is correct. If it is supposed to be a date literal, it is incorrect because the month component is too high.

  11. Correct; date data type.

  12. Correct; time data type.

  13. If it is supposed to be an alphanumeric literal, it is correct. If it is supposed to be a time literal, it is incorrect because if the hours component is equal to 24, the two other components must be equal to 0.

  14. Correct; timestamp data type.

  15. Incorrect; a hexadecimal data type must consist of an even number of characters.

  16. Correct; Boolean data type

5.2

The value of a literal is fixed; that of an expression must be determined by SQL.

5.3

Expressions can be grouped based on their respective data types, the complexity of their values, and their forms. Grouping based on data type refers to the data type of the value of the expression, such as integer, date, or alphanumeric. Grouping based on complexity refers to whether it is a "normal," a row or a table expression. Grouping based on form implies whether it is a singular or compound expression.

5.4

SELECT   MATCHNO, WON - LOST AS DIFFERENCE
FROM     MATCHES

5.5

Yes, this statement is correct. It is allowed to sort on column headings.

5.6

SELECT   PLAYERS.PLAYERNO, PLAYERS.NAME,
         PLAYERS.INITIALS
FROM     PLAYERS
WHERE    PLAYERS.PLAYERNO > 6
ORDER BY PLAYERS.NAME

5.7

This statement is incorrect because of the column specification TEAMS.PLAYERNO. The TEAMS table does not occur in the FROM clause; therefore, the SQL statement cannot refer to columns of this table.

5.8

SELECT   PRIVILEGE, WITHGRANTOPT
FROM     DATABASE_AUTHS
WHERE    GRANTOR = CURRENT_USER

5.9

SELECT   PLAYERNO
FROM     COMMITTEE_MEMBERS
WHERE    BEGIN_DATE = CURRENT_DATE

5.10

SELECT   TEAMNO,
         CASE DIVISION
            WHEN 'first' then 'first division'
            WHEN 'second' THEN 'second division'
            ELSE 'unknown' END AS DIVISION
FROM     TEAMS

5.11

SELECT   PAYMENTNO, AMOUNT,
         CASE
            WHEN AMOUNT >= 0 AND AMOUNT <= 40
               THEN 'low'
            WHEN AMOUNT >= 41 AND AMOUNT <= 80
               THEN 'moderate'
            WHEN AMOUNT >= 81
               THEN 'high'
            ELSE 'incorrect' END AS CATEGORY
FROM     PENALTIES

5.12

SELECT   PAYMENTNO, AMOUNT
FROM     PENALTIES
WHERE    CASE
            WHEN AMOUNT >= 0 AND AMOUNT <= 40
               THEN 'low'
            WHEN AMOUNT > 40 AND AMOUNT <= 80
               THEN 'moderate'
            WHEN AMOUNT > 80
               THEN 'high'
            ELSE 'incorrect' END = 'low'

5.13

  100
  0
  9
  SQL
  deeteebeese

5.14

SELECT   PAYMENTNO
FROM     PENALTIES
WHERE    DAYNAME(PAYMENT_DATE) = 'Monday'

5.15

SELECT   PAYMENTNO
FROM     PENALTIES
WHERE    YEAR(PAYMENT_DATE) = 1984

5.16

CAST('2004-03-12' AS DATE)

5.17

Alphanumeric literal

5.18

Not every alphanumeric literal can be converted. It is possible only when the literal satisfies the requirements of a date. Converting a date literal to an alphanumeric literal always works.

5.19

No. When the NULL value is compared to another expression with an equal to operator, the entire condition evaluates to unknown and the corresponding row is not included in the end result.

5.20

Not a single row.

5.21

200
3800
200
200
333,33
111,11
150,0000

5.22

SELECT   PLAYERNO, SUBSTR(INITIALS,1,1) || '. ' || NAME
FROM     PLAYERS

5.23

SELECT   TEAMNO, RTRIM(DIVISION) || ' division'
FROM     TEAMS

5.24

2000-03-07
2000-01-29
2000-02-29
2001-03-01
2001-02-28

5.25

SELECT   PLAYERNO, BEGIN_DATE,
         BEGIN_DATE + INTERVAL 2 MONTH + INTERVAL 3 DAY
FROM     COMMITTEE_MEMBERS

5.26

ADDTIME('11:34:34', '10:00:00')

5.27

35:34:34

5.28

'1995-12-12 11:34:34' + INTERVAL 1000 MINUTE

5.29

SELECT   PAYMENTNO, PAYMENT_DATE,
         PAYMENT_DATE + INTERVAL 3 HOUR +
         INTERVAL 50 SECOND + INTERVAL 99 MICROSECOND
FROM     PENALTIES

5.30

SELECT   PAYMENTNO
FROM     PENALTIES
WHERE    (AMOUNT, PLAYERNO, PAYMENT_DATE) =
         (25, 44, '1980-12-08')

5.31

SELECT   PLAYERNO
FROM     PLAYERS
WHERE    (NAME, INITIALS) = (TOWN, STREET)



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows