Академический Документы
Профессиональный Документы
Культура Документы
Page 2 of 14
INSERT INTO
tablename (column name,column name,,,,,) VALUES (value1,value2,,,,,,) WHERE predicate or (subselect statement)
DB2_Tr Ver. 1.0.0 04/12/1998 Page 3 of 14
UPDATE SET
tablename column name = expression or value ,column name = expression or value ..........
WHERE predicate
DB2_Tr Ver. 1.0.0 04/12/1998 Page 4 of 14
Page 5 of 14
Page 6 of 14
ORDER BY Clause
Is the only way to guarantee the sequence of the rows returned from a query Must be the last clause of a SELECT ORDER BY expressions are limited to SELECTed columns or positions May be ASCending or DESCending
Page 7 of 14
Example 25
Page 8 of 14
DISTINCT Qualifier
References the entire SELECT list Used to eliminate duplicate rows from the result table
Page 9 of 14
Example 26/27/28
select distinct department, job from staff where years > 10;
Page 10 of 14
GROUP BY
Returns one row for each value of the specified column If used, must appear after the WHERE clause and before the ORDER BY clause Must use a column name The GROUP BY column must be SELECTed The SELECTed columns must be named in the GROUP BY clause unless they are used with a column function
Page 11 of 14
Example 29
Page 12 of 14
Example 30/31
Page 13 of 14
HAVING Clause
Used with GROUP BY clause is mentioned here but is not relevant until the unit on column functions
Page 14 of 14