{"id":1085,"date":"2018-01-13T07:34:14","date_gmt":"2018-01-13T14:34:14","guid":{"rendered":"https:\/\/sqltutorial.org\/?page_id=1085"},"modified":"2025-01-25T03:32:46","modified_gmt":"2025-01-25T10:32:46","slug":"sql-aggregate-functions","status":"publish","type":"page","link":"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/","title":{"rendered":"SQL Aggregate Functions"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn about the SQL aggregate functions including <code>AVG()<\/code>, <code>COUNT()<\/code>, <code>MIN()<\/code>, <code>MAX()<\/code>, and <code>SUM()<\/code>.<\/p>\n\n\n\n<p>An SQL aggregate function calculates on a set of values and returns a single value. For example, the average function <code>AVG<\/code> takes a list of values and returns the average.<\/p>\n\n\n\n<p>Since an aggregate function operates\u00a0on a set of values, it is often used with the <code><a href=\"https:\/\/www.sqltutorial.org\/sql-group-by\/\">GROUP BY<\/a><\/code> clause of the <code><a href=\"https:\/\/www.sqltutorial.org\/sql-select\/\">SELECT<\/a><\/code> statement. The <code>GROUP BY<\/code> clause divides the result set into groups of values and the aggregate function returns a single value for each group.<\/p>\n\n\n\n<p>The following illustrates how the aggregate function is used with the <code><a href=\"https:\/\/www.sqltutorial.org\/sql-group-by\/\">GROUP BY<\/a><\/code> clause:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> c1, aggregate_function(c2)\n<span class=\"hljs-keyword\">FROM<\/span> <span class=\"hljs-keyword\">table<\/span>\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> c1;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following are the commonly used SQL aggregate functions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u00a0<code><a href=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/sql-avg\/\">AVG()<\/a><\/code> &#8211; returns the average of a set.<\/li>\n\n\n\n<li>\u00a0<a href=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/sql-count\/\"><code>COUNT()<\/code><\/a> &#8211; returns the number of items in a set.<\/li>\n\n\n\n<li>\u00a0<a href=\"https:\/\/www.sqltutorial.org\/sql-max\/\"><code>MAX()<\/code><\/a> &#8211; returns the maximum value in a set.<\/li>\n\n\n\n<li>\u00a0<a href=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/sql-min\/\"><code>MIN()<\/code><\/a> &#8211; returns the minimum value in a set<\/li>\n\n\n\n<li>\u00a0<a href=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/sql-sum\/\"><code>SUM()<\/code><\/a> &#8211; returns the sum of all or distinct values in a set<\/li>\n<\/ul>\n\n\n\n<p>Except for the <code>COUNT()<\/code> function, SQL aggregate functions ignore <code>NULL<\/code>.<\/p>\n\n\n\n<p>You can use aggregate functions as expressions only in the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The select list of a <code><a href=\"https:\/\/www.sqltutorial.org\/sql-select\/\">SELECT<\/a><\/code> statement, either a <a href=\"https:\/\/www.sqltutorial.org\/sql-subquery\/\">subquery<\/a> or an outer query.<\/li>\n\n\n\n<li>A <code><a href=\"https:\/\/www.sqltutorial.org\/sql-having\/\">HAVING<\/a><\/code> clause<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='avg'>AVG <a href=\"#avg\" class=\"anchor\" id=\"avg\" title=\"Anchor for AVG\">#<\/a><\/h2>\n\n\n\n<p>The <code><a href=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/\">AVG()<\/a><\/code> function returns the average values in a set. The following illustrates the syntax of the <code>AVG()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">AVG( ALL | DISTINCT)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>ALL<\/code> keyword instructs the <code>AVG()<\/code> function to calculate the average of all values while the <code>DISTINCT<\/code> keyword forces the function to operate on distinct values only. By default, the <code>ALL<\/code> option is used.<\/p>\n\n\n\n<p>The following example shows how to use the <code>AVG()<\/code> function to calculate the average salary of each department:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    department_name, <span class=\"hljs-keyword\">ROUND<\/span>(<span class=\"hljs-keyword\">AVG<\/span>(salary), <span class=\"hljs-number\">0<\/span>) avg_salary\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n        <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span>\n    departments <span class=\"hljs-keyword\">USING<\/span> (department_id)\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> department_name\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> department_name;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"196\" height=\"237\" src=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-AVG.png\" alt=\"SQL Aggregate Functions - AVG\" class=\"wp-image-1086\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='min'>MIN <a href=\"#min\" class=\"anchor\" id=\"min\" title=\"Anchor for MIN\">#<\/a><\/h2>\n\n\n\n<p>The <code><a href=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/sql-min\/\">MIN()<\/a><\/code> function returns the minimum value of a set. The following illustrates the syntax of the <code>MIN()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">MIN(column | expression)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example, the following statement returns the minimum salary of the employees in each department:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    department_name, <span class=\"hljs-keyword\">MIN<\/span>(salary) min_salary\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n        <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span>\n    departments <span class=\"hljs-keyword\">USING<\/span> (department_id)\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> department_name\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> department_name;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"190\" height=\"235\" src=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-MIN.png\" alt=\"SQL Aggregate Functions - MIN\" class=\"wp-image-1087\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='max'>MAX <a href=\"#max\" class=\"anchor\" id=\"max\" title=\"Anchor for MAX\">#<\/a><\/h2>\n\n\n\n<p>The <code><a href=\"https:\/\/www.sqltutorial.org\/sql-max\/\">MAX()<\/a><\/code> function returns the maximum value of a set. The <code>MAX()<\/code> function has the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">MAX(column | expression)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example, the following statement returns the highest salary of employees in each department:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    department_name, <span class=\"hljs-keyword\">MAX<\/span>(salary) highest_salary\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n        <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span>\n    departments <span class=\"hljs-keyword\">USING<\/span> (department_id)\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> department_name\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> department_name;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"208\" height=\"240\" src=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-MAX.png\" alt=\"SQL Aggregate Functions - MAX\" class=\"wp-image-1088\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='count'>COUNT <a href=\"#count\" class=\"anchor\" id=\"count\" title=\"Anchor for COUNT\">#<\/a><\/h2>\n\n\n\n<p>The <code><a href=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/sql-count\/\">COUNT()<\/a><\/code> function returns the number of items in a set. The following shows the syntax of the <code>COUNT()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">COUNT ( &#91;ALL | DISTINCT] column | expression | *)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example, the following example uses the <code>COUNT(*)<\/code> function to return the headcount of each department:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    department_name, <span class=\"hljs-keyword\">COUNT<\/span>(*) headcount\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n        <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span>\n    departments <span class=\"hljs-keyword\">USING<\/span> (department_id)\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> department_name\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> department_name;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"194\" height=\"243\" src=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-COUNT.png\" alt=\"SQL Aggregate Functions - COUNT\" class=\"wp-image-1089\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='sum'>SUM <a href=\"#sum\" class=\"anchor\" id=\"sum\" title=\"Anchor for SUM\">#<\/a><\/h2>\n\n\n\n<p>The <code><a href=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/sql-sum\/\">SUM()<\/a><\/code> function returns the sum of all values. The following illustrates the syntax of the <code>SUM()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">SUM(ALL | DISTINCT column)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example, the following statement returns the total salary of all employees in each department:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    department_id, <span class=\"hljs-keyword\">SUM<\/span>(salary)\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> department_id;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"196\" height=\"241\" src=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-SUM.png\" alt=\"SQL Aggregate Functions - SUM\" class=\"wp-image-1090\"\/><\/figure>\n\n\n\n<p>In this tutorial, you have learned the most commonly used SQL aggregate functions including <code>AVG()<\/code>, <code>COUNT()<\/code>, <code>MIN()<\/code>, <code>MAX()<\/code>, and <code>SUM()<\/code> functions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn about the SQL aggregate functions including AVG(), COUNT(), MIN(), MAX(), and SUM().<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":62,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1085","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Aggregate Functions<\/title>\n<meta name=\"description\" content=\"This tutorial introduces you to the most commonly used SQL aggregate functions including AVG, COUNT, MAX, MIN and SUM functions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Aggregate Functions\" \/>\n<meta property=\"og:description\" content=\"This tutorial introduces you to the most commonly used SQL aggregate functions including AVG, COUNT, MAX, MIN and SUM functions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-25T10:32:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-AVG.png\" \/>\n\t<meta property=\"og:image:width\" content=\"196\" \/>\n\t<meta property=\"og:image:height\" content=\"237\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/\",\"url\":\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/\",\"name\":\"SQL Aggregate Functions\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqltutorial.org\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-AVG.png\",\"datePublished\":\"2018-01-13T14:34:14+00:00\",\"dateModified\":\"2025-01-25T10:32:46+00:00\",\"description\":\"This tutorial introduces you to the most commonly used SQL aggregate functions including AVG, COUNT, MAX, MIN and SUM functions.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/#primaryimage\",\"url\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-AVG.png\",\"contentUrl\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-AVG.png\",\"width\":196,\"height\":237,\"caption\":\"SQL Aggregate Functions - AVG\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqltutorial.org\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Aggregate Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqltutorial.org\/#website\",\"url\":\"https:\/\/www.sqltutorial.org\/\",\"name\":\"SQL Tutorial\",\"description\":\"An Interactive SQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqltutorial.org\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Aggregate Functions","description":"This tutorial introduces you to the most commonly used SQL aggregate functions including AVG, COUNT, MAX, MIN and SUM functions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/","og_locale":"en_US","og_type":"article","og_title":"SQL Aggregate Functions","og_description":"This tutorial introduces you to the most commonly used SQL aggregate functions including AVG, COUNT, MAX, MIN and SUM functions.","og_url":"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/","og_site_name":"SQL Tutorial","article_modified_time":"2025-01-25T10:32:46+00:00","og_image":[{"width":196,"height":237,"url":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-AVG.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/","url":"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/","name":"SQL Aggregate Functions","isPartOf":{"@id":"https:\/\/www.sqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/#primaryimage"},"image":{"@id":"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-AVG.png","datePublished":"2018-01-13T14:34:14+00:00","dateModified":"2025-01-25T10:32:46+00:00","description":"This tutorial introduces you to the most commonly used SQL aggregate functions including AVG, COUNT, MAX, MIN and SUM functions.","breadcrumb":{"@id":"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/#primaryimage","url":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-AVG.png","contentUrl":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/01\/SQL-Aggregate-Functions-AVG.png","width":196,"height":237,"caption":"SQL Aggregate Functions - AVG"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"SQL Aggregate Functions"}]},{"@type":"WebSite","@id":"https:\/\/www.sqltutorial.org\/#website","url":"https:\/\/www.sqltutorial.org\/","name":"SQL Tutorial","description":"An Interactive SQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/1085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/comments?post=1085"}],"version-history":[{"count":0,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/1085\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/media?parent=1085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}