Syntax: SUM([DISTINCT]|[ALL] ) : SUM « Aggregate Functions « Oracle PL / SQL






Syntax: SUM([DISTINCT]|[ALL] )

   
SQL>
SQL> CREATE TABLE MyProduct
  2  (
  3    MAKER  VARCHAR (25),
  4    MODEL  VARCHAR (25),
  5    PRICE  NUMERIC
  6  );

Table created.

SQL>
SQL> INSERT INTO MyProduct VALUES('CHRYSLER','CROSSFIRE',33620);

1 row created.

SQL> INSERT INTO MyProduct VALUES('CHRYSLER','300M',29185);

1 row created.

SQL> INSERT INTO MyProduct VALUES('HONDA','CIVIC',15610);

1 row created.

SQL> INSERT INTO MyProduct VALUES('HONDA','ACCORD',19300);

1 row created.

SQL>
SQL> INSERT INTO MyProduct VALUES('FORD','MUSTANG',15610);

1 row created.

SQL> INSERT INTO MyProduct VALUES('FORD','LATESTnGREATEST',NULL);

1 row created.

SQL> INSERT INTO MyProduct VALUES('FORD','FOCUS',13005);

1 row created.

SQL>
SQL> SELECT
  2     SUM(price) total
  3  FROM MyProduct;

   TOTAL
--------
########

SQL> drop table MyProduct;

Table dropped.

SQL>
SQL>

   
    
  








Related examples in the same category

1.SUM: total for all NOT NULL values, accepts only numeric datatype values
2.GROUP BY function would produce inventory totals distributed across different vendors
3.SUM function and NULLs
4.Using the SUM function with GROUP BY Clause
5.sum with column calculation
6.Add an "OTHER" and "TOTAL" column to the report:
7.Compute sum on salary
8.Sum column for a certain time period
9.Sum salary group by department number
10.Sum salary over
11.Sum() function and having clause
12.Doing calculation in sum() function
13.Wrap case when into sum() function