answersLogoWhite

0

Aggregate Functions in SQL Part 1: Introducing SUM and AVGMore of this Feature• Part 2: Counting Records

• Part 3: Max and Min

Join the Discussion"Need some assistance or advice? Join us in the About Databases forum."

Mike Chapple

By their very nature, our databases contain a lot of data. In previous features, we've explored methods of extracting the specific data we're looking for using the Structured Query Language (SQL). Those methods worked great when we were seeking the proverbial needle in the haystack. We were able to answer obscure questions like "What are the last names of all customers who have purchased Siberian wool during the slow months of July and August?"

Oftentimes, we're also interested in summarizing our data to determine trends or produce top-level reports. For example, the purchasing manager may not be interested in a listing of all widget sales, but may simply want to know the number of widgets sold this month. Fortunately, SQL provides aggregate functions to assist with the summarization of large volumes of data. In this three-segment article, we'll look at functions that allow us to add and average data, count records meeting specific criteria and find the largest and smallest values in a table.

All of our queries will use the WidgetOrder table described below. Please note that this table is not normalized and I've combined several data entities into one table for the purpose of simplifying this scenario. A good relational design would likely have Products, Orders, and Customers tables at a minimum.Aggregate Functions in SQL Part 1: Introducing SUM and AVGMore of this Feature• Part 2: Counting Records

• Part 3: Max and Min

Join the Discussion"Need some assistance or advice? Join us in the About Databases forum."

Mike Chapple

By their very nature, our databases contain a lot of data. In previous features, we've explored methods of extracting the specific data we're looking for using the Structured Query Language (SQL). Those methods worked great when we were seeking the proverbial needle in the haystack. We were able to answer obscure questions like "What are the last names of all customers who have purchased Siberian wool during the slow months of July and August?"

Oftentimes, we're also interested in summarizing our data to determine trends or produce top-level reports. For example, the purchasing manager may not be interested in a listing of all widget sales, but may simply want to know the number of widgets sold this month. Fortunately, SQL provides aggregate functions to assist with the summarization of large volumes of data. In this three-segment article, we'll look at functions that allow us to add and average data, count records meeting specific criteria and find the largest and smallest values in a table.

All of our queries will use the WidgetOrder table described below. Please note that this table is not normalized and I've combined several data entities into one table for the purpose of simplifying this scenario. A good relational design would likely have Products, Orders, and Customers tables at a minimum.Aggregate Functions in SQL Part 1: Introducing SUM and AVGMore of this Feature• Part 2: Counting Records

• Part 3: Max and Min

Join the Discussion"Need some assistance or advice? Join us in the About Databases forum."

Mike Chapple

By their very nature, our databases contain a lot of data. In previous features, we've explored methods of extracting the specific data we're looking for using the Structured Query Language (SQL). Those methods worked great when we were seeking the proverbial needle in the haystack. We were able to answer obscure questions like "What are the last names of all customers who have purchased Siberian wool during the slow months of July and August?"

Oftentimes, we're also interested in summarizing our data to determine trends or produce top-level reports. For example, the purchasing manager may not be interested in a listing of all widget sales, but may simply want to know the number of widgets sold this month. Fortunately, SQL provides aggregate functions to assist with the summarization of large volumes of data. In this three-segment article, we'll look at functions that allow us to add and average data, count records meeting specific criteria and find the largest and smallest values in a table.

All of our queries will use the WidgetOrder table described below. Please note that this table is not normalized and I've combined several data entities into one table for the purpose of simplifying this scenario. A good relational design would likely have Products, Orders, and Customers tables at a minimum.

Sourced From:

about.com

http://databases.about.com/od/sql/l/aaaggregate1.htm

By their very nature, our databases contain a lot of data. In previous features, we've explored methods of extracting the specific data we're looking for using the Structured Query Language (SQL). Those methods worked great when we were seeking the proverbial needle in the haystack. We were able to answer obscure questions like "What are the last names of all customers who have purchased Siberian wool during the slow months of July and August?"

Oftentimes, we're also interested in summarizing our data to determine trends or produce top-level reports. For example, the purchasing manager may not be interested in a listing of all widget sales, but may simply want to know the number of widgets sold this month. Fortunately, SQL provides aggregate functions to assist with the summarization of large volumes of data. In this three-segment article, we'll look at functions that allow us to add and average data, count records meeting specific criteria and find the largest and smallest values in a table.

All of our queries will use the WidgetOrder table described below. Please note that this table is not normalized and I've combined several data entities into one table for the purpose of simplifying this scenario. A good relational design would likely have Products, Orders, and Customers tables at a minimum.

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

List two reasons why null values might be introducedin database?

1. special requirements for its use in SQL joins. 2. special handling required by aggregate functions and SQL grouping operators


What are date functions in My Sql?

There are many date functions in My Sql. One may find a list of these date functions by visiting sites dedicated to My SQL functions such as w3Schools.


What are some examples of SQL?

SQL is short for Structured query language. Examples of SQL are seleect * from table_name where <predicates>;


Examples for dbms and rdbms?

My sql, Microsoft sql , Microsoft Access, dBase, Filemaker pro are the examples for dbms and oracle and sql server are the examples for rdbms


What date functions exist in SQL?

The date functions that exist in SQL are "NOW()", "CURDATE()", "CURTIME()", "DATE()", "EXTRACT()", "DATEDIFF()", "GETDATE()", "DATEPART()", and "CONVERT()".


Function that performs a mathematical function against a group of records?

You can create a function in a programming language like Python or SQL that takes a group of records as input and performs a mathematical operation on them. This function would iterate through the records, apply the specified mathematical operation, and return the result. For example, in SQL you can use aggregate functions like SUM, AVG, MAX, MIN, etc. to perform calculations on groups of records.


Where can one find out how to do sql date format?

You can find information on SQL date formats in the documentation of the specific database management system you are using, such as MySQL, SQL Server, or PostgreSQL. These documents typically include details on how to format dates in SQL queries and functions. Additionally, online tutorials and forums can provide examples and guidance on SQL date formatting.


What is the purpose of the AS command in SQL?

If you are in search of learning the purpose of the AS command in SQL, there are a few resources that are available to you. One resource that can explain the purpose of the AS command in SQL is Wikipedia.


What are the are two sort functions for columns in SQL?

Asc & desc


Can you uses sql stored procedure in qlikview and if you can script examples please?

In qlikview: SQL EXEC [dbo].[StoredProcedureName];


What is the Oracle Developer Responsibility?

SQL, PL/SQL, Forms and Reports Development, Database Design, Stored Procedures, Functions, Triggers


Two examples of database?

1. oracle 2. My SQL