Showing posts with label max. Show all posts
Showing posts with label max. Show all posts

Saturday, January 2, 2016

SQL -- Aggregate Functions (Group by, MIN, MAX)


From the items_ordered table, select the item, maximum price, and minimum price for each specific item in the table. 







SELECT item, MAX(price), MIN(price)

FROM items_ordered

GROUP BY item;

Saturday, October 24, 2015

SQL -- Aggregate Functions

The following example summarize the numeric results of a column. Here a list of agregate funtions:


MIN
returns the smallest value in a given column
MAX
returns the largest value in a given column
SUM
returns the sum of the numeric values in a given column
AVG
returns the average value of a given column
COUNT
returns the total number of values in a given column
COUNT(*)
returns the number of rows in a table





Here is an example of selecting the maximum price of any item ordered in the item_ordered table.



SELECT MAX(price)
FROM items_ordered;