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






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

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

Table created.

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

1 row created.

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

1 row created.

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

1 row created.

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

1 row created.

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

1 row created.

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

1 row created.

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

1 row created.

SQL>
SQL>
SQL> SELECT
  2     COUNT(*) cars_count
  3  FROM cars;

CARS_COUNT
----------
      7.00

SQL>
SQL>
SQL> drop table cars;

Table dropped.

SQL>

   
    
  








Related examples in the same category

1.COUNT(column) and COUNT(*): count the number of rows passed into the function.
2.Using GROUP BY would tell us how many cars from each vendor we have on the lot:
3.Find out which maker has a null value car with count()
4.-Using the COUNT function in Having clause
5.Example using the COUNT function with group by clause
6.Count with group by: count for a group value
7.Get the number of rows in each city group using the COUNT() function
8.count null
9.Column alias name for count function
10.Count(*) - count(column_Name)
11.count distinct column value
12.count(1)
13.count(distinct state)
14.Count(*) and column renaming
15.Count() with where clause
16.Count date field value, and calculation
17.Count department and calculate average salary
18.Count employee in a department after grouping by department id
19.Count employee, group by department id and job title
20.count(*) - count(onhand)
21.count(*) vs count(column name)