SQL LCASE Functions
The AVG()
function returns the average value of a numeric column.
SQL AVG() Syntax:
SELECT AVG(Column) FROM Table
Example
We have the following "Orders" table:
OrderID | Customer | Date | OrderPrice |
---|---|---|---|
1 | Jones | 2012/01/01 | 1000 |
2 | Smith | 2012/01/02 | 1600 |
3 | Watson | 2012/01/02 | 700 |
4 | Jones | 2012/01/03 | 300 |
5 | Brown | 2012/01/03 | 2000 |
6 | Smith | 2012/01/04 | 1000 |
Now we want to find the average value of the "OrderPrice" fields.
We use the following SQL statement:
SELECT AVG(OrderPrice) AS OrderAverage FROM Orders
The result-set will look like this:
OrderAverage: 950