Aggregation

Syntax:

SELECT  f(x) ...... FROM T

Parameter:

T

Table name

f(x)

Aggregate function f on generalized field expression x

Example:

 

SELECT SellerID,sum(Amount) FROM ReturnedPmt  BY SellerID

Group by SellerID and sum values under Amount field

SELECT

  CustomerID.CustName,

  sum(Amount) Total

 FROM

  ReturnedPmt

BY

  CustomerID

 

 

Learning point:

1)  A primary table is a table where part of the primary key is pointed by the foreign key in another table; a dimension table of a level function with a single-field primary key; the primary table’s primary table; a homo-dimension table’s primary table; the primary table’s homo-dimension table. The last case requires that primary keys of the primary table and the sub table correspond in order.

1)