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

Home
Oracle PL / SQL
1.Aggregate Functions
2.Analytical Functions
3.Char Functions
4.Constraints
5.Conversion Functions
6.Cursor
7.Data Type
8.Date Timezone
9.Hierarchical Query
10.Index
11.Insert Delete Update
12.Large Objects
13.Numeric Math Functions
14.Object Oriented Database
15.PL SQL
16.Regular Expressions
17.Report Column Page
18.Result Set
19.Select Query
20.Sequence
21.SQL Plus
22.Stored Procedure Function
23.Subquery
24.System Packages
25.System Tables Views
26.Table
27.Table Joins
28.Trigger
29.User Previliege
30.View
31.XML
Oracle PL / SQL » Aggregate Functions » MIN 
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);

row created.

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

row created.

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

row created.

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

row created.

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

row created.

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

row created.

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

row created.

SQL>
SQL> SELECT
  2     Maker,
  3     MAX(pricemax_price,
  4     MIN(pricemin_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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.