To find the price range for the cars on the lot in relation to the manufacturer, the GROUP BY clause must be used : MIN « Aggregate Functions « Oracle PL / SQL






To find the price range for the cars on the lot in relation to the manufacturer, the GROUP BY clause must be used

 
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> SELECT
  2     Maker,
  3     MAX(price) max_price,
  4     MIN(price) min_price
  5  FROM cars
  6  GROUP BY maker;
SQL>
SQL>
SQL> drop table cars;

Table dropped.

SQL>
SQL>

 








Related examples in the same category

1.MIN: return the lowest values in a column, ignores NULLs
2.Syntax: MIN([DISTINCT]|[ALL] )
3.MIN with dates, it gives you the oldest dates
4.MIN with character data, retrieves the lowest value alphabetically (that is, closest to 'a')
5. Example using the MIN function with having clause
6.Example using the MIN function with group by clause
7.Min with null value