Difference between revisions of "TYPES"

From rbachwiki
Jump to navigation Jump to search
(Created page with "==MIN()Returns the smallest Value== ==MAX() Returns the largest Value == ==SUM() Returns the sum of values == ==AVG() Returns the Average of Values == ==COUNT() Returns th...")
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
==MIN()Returns the smallest Value==
==MIN()Returns the smallest Value==
SELECT COUNT(*), SUM(TOTAL_AMOUNT), MIN(TOTAL_AMOUNT) from sales;
'''Returns the count in one column, the sum of the total_amount column and Min amount'''


==MAX() Returns the largest Value ==
==MAX() Returns the largest Value ==
'''Ignores Null values'''
SELECT MAX(customer#)
FROM orders;


==SUM() Returns the sum of values ==
==SUM() Returns the sum of values ==
'''Returns the count in one column and the sum of the total_amount column'''
SELECT COUNT(*), SUM(TOTAL_AMOUNT) from sales;
SELECT sum((paideach-cost)*quantity) "Total Profit"
FROM orderitems JOIN books USING (isbn)
WHERE order# = 1007


==AVG() Returns the Average of Values ==
==AVG() Returns the Average of Values ==
SELECT AVG(cost)
FROM books;


==COUNT() Returns the number or rows ==
==COUNT() Returns the number or rows ==
''' Returns the record count'''
SELECT COUNT(*) FROM SALES
'''Count all orders not yet shipped'''
SELECT COUNT(*) "ORDERS NOT SHIPPED"
FROM orders
WHERE shipdate IS NULL;
==VARIANCE ==
'''Returns the variance - ignores NULL values'''
SELECT VARIANCE(retail)
FROM books;


==FIRST() Returns the first value of the group==
==FIRST() Returns the first value of the group==


==LAST() Returns the last value of the group==
==LAST() Returns the last value of the group==
[[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]]

Latest revision as of 21:12, 7 November 2017

MIN()Returns the smallest Value

SELECT COUNT(*), SUM(TOTAL_AMOUNT), MIN(TOTAL_AMOUNT) from sales;

Returns the count in one column, the sum of the total_amount column and Min amount

MAX() Returns the largest Value

Ignores Null values

SELECT MAX(customer#)
FROM orders;

SUM() Returns the sum of values

Returns the count in one column and the sum of the total_amount column

SELECT COUNT(*), SUM(TOTAL_AMOUNT) from sales;
SELECT sum((paideach-cost)*quantity) "Total Profit"
FROM orderitems JOIN books USING (isbn)
WHERE order# = 1007

AVG() Returns the Average of Values

SELECT AVG(cost)
FROM books;

COUNT() Returns the number or rows

Returns the record count

SELECT COUNT(*) FROM SALES

Count all orders not yet shipped

SELECT COUNT(*) "ORDERS NOT SHIPPED"
FROM orders
WHERE shipdate IS NULL;

VARIANCE

Returns the variance - ignores NULL values

SELECT VARIANCE(retail)
FROM books;


FIRST() Returns the first value of the group

LAST() Returns the last value of the group

Back To Top- Home - Category