Find out which maker has a null value car with count()
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 Maker,
3 COUNT(*) total_count,
4 COUNT(price) car_prices
5 FROM cars
6 GROUP BY maker;
MAKER TOTAL_COUNT CAR_PRICES
------------------------- ----------- ----------
HONDA 2.00 2.00
FORD 3.00 2.00
CHRYSLER 2.00 2.00
SQL>
SQL>
SQL>
SQL> drop table cars;
Table dropped.
SQL>
Related examples in the same category