Fujitsu J2X0-1634-01EN Computer Accessories User Manual


 
Chapter 6 Methods of Manipulating Data
This chapter describes methods of using SQL statements to manipulate data.
This chapter contains the following sections:
6.1 Grouping Tables and Manipulating Data
6.2 Specifying Various Search Conditions
6.3 Manipulating Numeric Data
6.4 Manipulating Character String Data
6.5 Manipulating Date Data
6.6 Converting the Data Type to Manipulate Data
6.7 Using CASE Expression to Manipulate Data
6.8 Specifying Row IDs to Manipulate Data
6.9 Manipulating Data using Parallel Query
6.10 Omitting Schema Names
6.11 Changing the User of the Current Session
6.12 Adding a Name to a Results Column in Query Specification
6.13 Manipulating Data Using Sequence
6.1 Grouping Tables and Manipulating Data
When data is fetched from tables, the table can be grouped according to column values and data can be manipulated.
Grouping tables refers to a way of grouping rows in which a column or a group of columns have the same value. A
different group is formed from different rows. A table that has been grouped in this way is called a grouped table.
Specify the GROUP BY clause or the HAVING clause to group a table and manipulate data. The GROUP BY clause
and the HAVING clause can be specified in a table expression. If the FROM clause, WHERE clause, GROUP BY
clause, and HAVING clause are specified in the same table expression, the processing sequence is as follows:
1. FROM clause
2. WHERE clause
3. GROUP BY clause
4. HAVING clause
First, the rows in the table specified by the FROM clause are specified by the search conditions in the WHERE clause.
Next, the specified rows are grouped according to the GROUP BY clause. Then, the group is specified by the search
conditions in the HAVING clause.
6.1.1 Grouping tables and fetching data
Grouping tables
The first method of grouping tables is as follows:
Example 1:
In this example, the STOCK table is grouped according to the values for PRODUCT.
"Figure: Example of a table derived from GROUP BY clause" shows the table derived from the GROUP BY clause.
71