SQL: Functioning in the Real World - Minimum and Maximum
(Page 5 of 5 )
The Min(Column) and Max(Column) functions return the lowest and highest value in a column, respectively. If we wanted to see the highest pay rate in our Employees table, we would do the following:
Select Max(Salary) from Employees
This would return the value, $100,000. If we wanted to see the lowest salary, we would do this:
Select Min(Salary) from Employees
The result of this would be $12,000. Poor Ang Ree.
In Summation
Ha! I fooled you! You though this was the end of the article. Well you were wrong; I was using word play to trick your feeble mind.
You can use the Sum(Column) function to get a total of all the values in a column. If we wanted to know the annual salary of all of the employees in the Employee table, it would go a little something like this:
Select Sum(Salary) from Employees
This would add all of the values in the Salary column, resulting in the total: $342,000.
Well, that wraps it up for this part. In the next part we will cover the rest of the Aggregate Functions, and learn the Scalar functions as well. Look forward to seeing you.
Till then...
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |