DotNet Tutorials

V4 Dot Net Tutorials

Server Intellect Cloud Hosting

 SQL Aggregate Functions

This Tutorial will teach you how to use Aggregate Functions in SQL Queries.
Introduction
This Tutorial will teach you about all of the basic Aggregate functions in SQL.  These functions can be used to perform mathematical equations to SQL columns and allow you to pull this Data out of the table.  

Step 1. List of the Aggregate Functions
1. AVG() - Returns the average value
2. COUNT() - Returns the number of rows
3. FIRST() - Returns the first value
4. LAST() - Returns the last value
5. MAX() - Returns the largest value
6. MIN() - Returns the smallest value
7. SUM() - Returns the sum of all rows
All of these functions can be used in correspondence with the GROUP BY Function from our previous tutorial (here) in order to dive into the full functionality of the GROUP BY Function

Yes, it is possible to find a good web host. Sometimes it takes a while to find one you are comfortable with. After trying several, we went with Server Intellect and have been very happy thus far. They are by far the most professional, customer service friendly and technically knowledgeable host we've found so far.

Step 2. Basic Uses of the Aggregate Functions
The following SQL Queries are examples of how these Functions can be used.
1. In a SELECT Statement Grabbing the Sum of a Column

SELECT SUM(column_name) FROM table_name

This command will add up all of the numbers in a column and return them

2.Using the AS statement to name the returned value

SELECT SUM(OrderPrice) AS OrderTotal FROM Orders

when trying to use any of the numbers created it is always best to use the AS function.  The AS function names the number that is returned so that you can uses it when you like.
 
3. In a Where Clause Grabbing the Above average Customers

SELECT Customer FROM Orders
WHERE OrderPrice>(SELECT AVG(OrderPrice) FROM Orders)


This Function will grab the Customers whose OrderPrices are greater than the Average number of OrderPrices.  Notice the second SELECT Command is perfectly legal, this allows you to chain SELECT Commands to narrow down your results.

We used over 10 web hosting companies before we found Server Intellect. Our new cloud server,was set up in less than 24 hours. We were able to confirm our order over the phone. They responded to our inquiries within an hour. Server Intellect's customer support and assistance are the best we've ever experienced.

Conclusion
In this Tutorial we learned all about Aggregate Functions and how they can be used to simplify Mathematical equations on Table columns.  We also learned about their possible placements in SQL Queries and where they can be useful.

We used over 10 web hosting companies before we found Server Intellect. They offer dedicated servers, and they now offer cloud servers!