{"id":824,"date":"2019-12-05T14:41:58","date_gmt":"2019-12-05T09:11:58","guid":{"rendered":"https:\/\/binaryterms.com\/?p=824"},"modified":"2022-02-14T15:14:13","modified_gmt":"2022-02-14T09:44:13","slug":"aggregate-functions-in-sql","status":"publish","type":"post","link":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html","title":{"rendered":"Aggregate Functions in SQL"},"content":{"rendered":"<p>Aggregate functions in SQL evaluate the set of values and return a single value as a result. SQL has five aggregate functions count, average, maximum, minimum, sum. The aggregate functions, &#8216;sum&#8217; and &#8216;average&#8217; operate only on numeric values. While count, maximum, minimum can also operate on non-numeric data such as string.<\/p>\n<p>In this section, we will discuss the steps to evaluate aggregate functions. We will discuss types of aggregate functions. We will also look into the use of aggregate function along with the &#8216;group by&#8217; clause and &#8216;having&#8217; clause.<\/p>\n<p><span style=\"font-family: Raleway, sans-serif;font-size: 30px\">Content: Aggregate Function in DBMS<\/span><\/p>\n<ol>\n<li><a href=\"#HowtoAggregateData?\">How to Aggregate Data?<\/a><\/li>\n<li><a href=\"#AggregateFunctions\">Aggregate Functions<\/a><\/li>\n<li><a href=\"#AggregationwithGroupbyClause\">Aggregation with Group by Clause<\/a><\/li>\n<li><a href=\"#AggregationwithHavingClause\">Aggregation with Having Clause<\/a><\/li>\n<li><a href=\"#KeyTakeaways\">Key Takeaways<\/a><\/li>\n<\/ol>\n<p><a name=\"HowtoAggregateData?\"><\/a><\/p>\n<h3>How to aggregate data in SQL?<\/h3>\n<p>Step by step evaluation of the aggregate function in SQL.<\/p>\n<ol>\n<li>The first thing evaluated in the query is the <strong>&#8216;from&#8217;<\/strong> clause. The &#8216;from&#8217; clause evaluates the relation to be operated.<\/li>\n<li>Next to the &#8216;<strong>from<\/strong> &#8216;clause is the <strong>&#8216;where&#8217;<\/strong> clause. The predicate in the <strong>&#8216;where&#8217;<\/strong> clause is evaluated on the outcome of the <strong>&#8216;from&#8217;<\/strong> clause.<\/li>\n<li>If present, the tuples filtered by the &#8216;where&#8217; clause are then grouped using the &#8216;<strong>group by<\/strong>&#8216; clause. Else all the tuples filtered by the <strong>&#8216;where&#8217;<\/strong> clause are considered as one group.<\/li>\n<li>The <strong>&#8216;having&#8217;<\/strong> clause is then applied to each group formed by the &#8216;<strong>group by<\/strong>&#8216; clause. And the groups satisfying the <strong>&#8216;having&#8217;<\/strong> clause are then forwarded to the <strong>&#8216;select&#8217;<\/strong> clause.<\/li>\n<li>Then the <strong>&#8216;select&#8217;<\/strong> clause applies the aggregate function to the evaluated groups. And generates a <strong>single result tuple<\/strong> for each group.<\/li>\n<\/ol>\n<p><a name=\"AggregateFunctions\"><\/a><\/p>\n<h3>Define Aggregate Functions in DBMS<\/h3>\n<p>The aggregate functions are applied to the set of tuples. And as a result, they return a relation with a single attribute consisting of a single tuple value. It can also be applied to the group of &#8216;sets of tuples&#8217;. It results in a relation with a single attribute and one tuple for each group.<\/p>\n<p>All aggregate functions avoid &#8216;null values&#8217; excluding the (*) function. Count function has variations regarding Null values.<\/p>\n<p>Below is the list of all aggregate functions in SQL:<\/p>\n<ol>\n<li><a href=\"#Count(count)\">Count (count)<\/a><\/li>\n<li><a href=\"#Average(avg)\">Average (avg)<\/a><\/li>\n<li><a href=\"#Maximum(max)\">Maximum (max)<\/a><\/li>\n<li><a href=\"#Minimum(min)\">Minimum (min)<\/a><\/li>\n<li><a href=\"#Total(sum)\">Total (sum)<\/a><\/li>\n<\/ol>\n<p><strong>Note<\/strong>: We can <strong>name<\/strong> the attribute of the result relation obtained by aggregation using the <strong>&#8216;as&#8217;<\/strong> clause. We can use the &#8216;as&#8217; clause for all aggregate functions.<\/p>\n<h4>How to Use the Aggregate function in SQL?<br \/>\n<a name=\"Count(count)\"><\/a><\/h4>\n<h4>COUNT( ) Aggregate Function<\/h4>\n<p>This aggregate function counts the number of tuples in the relation. It has certain variations:<\/p>\n<ul>\n<li><strong>count(*)<\/strong><br \/>\nThis function returns the number of tuples, including those with &#8216;Null values&#8217;.<\/li>\n<li><strong>count(attribute_name)<\/strong><br \/>\nThis function counts all the tuples with &#8216;not-null values&#8217;.<\/li>\n<li><strong>count(distinct attribute_name)<\/strong><br \/>\nThis function eliminates tuples with &#8216;null values&#8217; and &#8216;duplicate values&#8217;. It only counts the tuples with not-null values and distinct values.<\/li>\n<\/ul>\n<p><strong>Example of COUNT( ) Aggregate Function:<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-830 size-full\" src=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg\" alt=\"teaches relation\" width=\"510\" height=\"470\" srcset=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg 510w, https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation-300x276.jpg 300w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/p>\n<p>If you want to count the number of instructors in the teaches relation then the query for this would be:<\/p>\n<p style=\"text-align: center\"><strong>select<\/strong> <strong>count<\/strong>(inst-id)<br \/>\n<strong>from<\/strong> teaches;<\/p>\n<p>The query above will return <strong>13<\/strong> as a result. Here the count function avoids Null values.<\/p>\n<p>Next, if we add the <strong>distinct<\/strong> keyword in the count function.<\/p>\n<p style=\"text-align: center\"><strong>select<\/strong> <strong>count<\/strong> (distinct inst-id)<br \/>\n<strong>from<\/strong> teaches;<\/p>\n<p>This query returns <strong>9<\/strong> as a \u2018distinct\u2019 keyword is used along with the attribute name in the count function. So, it has eliminated the duplicates along with null values.<\/p>\n<p>Now, in the next query if we apply <strong>*<\/strong> in count():<\/p>\n<p style=\"text-align: center\"><strong>select<\/strong> <strong>count<\/strong>(<strong>*<\/strong>)<br \/>\n<strong>from<\/strong> teaches;<\/p>\n<p>This query will return <strong>15<\/strong> as it has counted all the tuples including the Null values.<br \/>\n<a name=\"Average(avg)\"><\/a><\/p>\n<h4>Average &#8216;AVG()&#8217; Aggregate Function<\/h4>\n<p>The AVG() function returns the average of all the tuple values from a single attribute of a relation. Remember the duplicate tuples must retain while computing an average. Else it will show an incorrect answer. This function avoids the &#8216;Null value&#8217; in its input as it complicates the aggregation.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-831 size-full\" src=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/instructor-relation.jpg\" alt=\"instructor relation\" width=\"429\" height=\"404\" srcset=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/instructor-relation.jpg 429w, https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/instructor-relation-300x283.jpg 300w\" sizes=\"auto, (max-width: 429px) 100vw, 429px\" \/><strong>Example of AVG( ) Aggregate Function:<\/strong><\/p>\n<p>Evaluate \u201caverage salary of all the instructors teaching in Comp.Sci. department\u201d.<\/p>\n<p style=\"text-align: center\"><strong>Select<\/strong> <strong>avg<\/strong>(salary)<br \/>\n<strong>from<\/strong> instructor<br \/>\n<strong>where<\/strong> dept_name=\u2018Comp.Sci.\u2019;<\/p>\n<p>The result of this query will be a relation with a single attribute carrying a single record. This record holds a numerical value. The numerical value shows the average salary of all instructors teaching in Comp. Sci. department (<strong>result 73,333.333<\/strong>).<\/p>\n<p>You can also provide a meaningful name to the attribute of result relation, using the &#8216;as&#8217; clause. Else, the database system will give an arbitrary name to the attribute of the result relation. The query below shows how can we provide a name to the attribute of result relation?<\/p>\n<p style=\"text-align: center\"><strong>select<\/strong> <strong>avg<\/strong>(salary) <strong>as<\/strong> avg_salary<br \/>\n<strong>from<\/strong> instructor<br \/>\n<strong>where<\/strong> dept_name =\u2018Comp.Sci.\u2019<\/p>\n<h4><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-854 size-full\" src=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/average-aggregate-function-new-3.jpg\" alt=\"average aggregate function new 3\" width=\"435\" height=\"147\" srcset=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/average-aggregate-function-new-3.jpg 435w, https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/average-aggregate-function-new-3-300x101.jpg 300w\" sizes=\"auto, (max-width: 435px) 100vw, 435px\" \/><a name=\"Maximum(max)\"><\/a><\/h4>\n<h4>Maximum &#8216;MAX()&#8217; Aggregate Function<\/h4>\n<p>This function evaluates the maximum value among all the tuple values, of the specified attribute. Like other aggregate functions, the max() avoid the&#8217; null values&#8217; in its input.<\/p>\n<p><strong>Example of MAX( ) Aggregate Function:<\/strong><\/p>\n<p>The query below will result in the maximum salary of all the instructors.<\/p>\n<p style=\"text-align: center\"><strong>select<\/strong> <strong>max<\/strong>(salary) <strong>as<\/strong> max_salary<br \/>\n<strong>from<\/strong> instructor;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-856 size-full\" src=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/maximum-aggregate-function-1.jpg\" alt=\"maximum aggregate function 1\" width=\"391\" height=\"136\" srcset=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/maximum-aggregate-function-1.jpg 391w, https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/maximum-aggregate-function-1-300x104.jpg 300w\" sizes=\"auto, (max-width: 391px) 100vw, 391px\" \/><\/p>\n<p><a name=\"Minimum(min)\"><\/a><\/p>\n<h4>Minimum &#8216;MIN()&#8217; Aggregate Function<\/h4>\n<p><span data-offset-key=\"90ng3-0-0\">Contrary to max() is the min() aggregate function. It evaluates the <\/span><span class=\"complexword\"><span data-offset-key=\"90ng3-1-0\">minimum<\/span><\/span><span data-offset-key=\"90ng3-2-0\"> value<\/span><span data-offset-key=\"90ng3-2-1\"> among all the tuple values, of the specified <\/span><span data-offset-key=\"90ng3-2-2\">attribute<\/span><span data-offset-key=\"90ng3-2-3\">. The min() <\/span><span class=\"complexword\"><span data-offset-key=\"90ng3-3-0\">aggregate<\/span><\/span><span data-offset-key=\"90ng3-4-0\"> function avoid &#8216;null values&#8217; in its input. <\/span><\/p>\n<p><strong>Example of MIN( ) Aggregate Function:<\/strong><\/p>\n<p>To find the minimum salary of all instructors in the instructor relation we will write the query:<\/p>\n<p style=\"text-align: center\"><strong>select<\/strong> <strong>min<\/strong>(salary) <strong>as<\/strong> min_salary<br \/>\n<strong>from<\/strong> instructor;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-857 size-full\" src=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/min-aggregate-function-1.jpg\" alt=\"min aggregate function 1\" width=\"394\" height=\"145\" srcset=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/min-aggregate-function-1.jpg 394w, https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/min-aggregate-function-1-300x110.jpg 300w\" sizes=\"auto, (max-width: 394px) 100vw, 394px\" \/><br \/>\n<a name=\"Total(sum)\"><\/a><\/p>\n<h4>Total &#8216;SUM()&#8217; Aggregate Function<\/h4>\n<p>This function evaluates the sum of all the tuple values, of the specified attribute. Like average function, sum also drives on numerical values only. The sum function avoids the null values.<\/p>\n<p><strong>Example of SUM( ) Aggregate Function:<\/strong><\/p>\n<p>The query below will find the total salary of all the instructors.<\/p>\n<p style=\"text-align: center\"><strong>select<\/strong> <strong>sum<\/strong>(salary) <strong>as<\/strong> sum_salary<br \/>\n<strong>from<\/strong> instructor;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-858 size-full\" src=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/sum-aggregate-function-1.jpg\" alt=\"sum aggregate function 1\" width=\"394\" height=\"137\" srcset=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/sum-aggregate-function-1.jpg 394w, https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/sum-aggregate-function-1-300x104.jpg 300w\" sizes=\"auto, (max-width: 394px) 100vw, 394px\" \/><\/p>\n<p><a name=\"AggregationwithGroupbyClause\"><\/a><\/p>\n<h3>&#8216;Group by&#8217; with Aggregate Function<\/h3>\n<p><span data-offset-key=\"e11ja-0-0\">We can apply <\/span><span class=\"complexword\"><span data-offset-key=\"e11ja-1-0\">aggregate<\/span><\/span><span data-offset-key=\"e11ja-2-0\"> functions to a group formed by the &#8216;group by clause&#8217;. The tuples with the same value for the specified attributes in the &#8216;group by&#8217; clause lies in one group.<\/span><\/p>\n<p><strong>Example of &#8216;Group by&#8217; Aggregate Function:<\/strong><\/p>\n<p>So, if we have to calculate the total salary of instructors in each department then the query would be:<\/p>\n<p style=\"text-align: center\"><strong>select<\/strong> dept_name <strong>sum<\/strong>(salary) <strong>as<\/strong> sum_salary<br \/>\n<strong>from<\/strong> instructor<br \/>\n<strong>group by<\/strong> dept_name;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-859 size-full\" src=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/group-by-clause-1.jpg\" alt=\"group by clause 1\" width=\"351\" height=\"253\" srcset=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/group-by-clause-1.jpg 351w, https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/group-by-clause-1-300x216.jpg 300w\" sizes=\"auto, (max-width: 351px) 100vw, 351px\" \/><\/p>\n<p><a name=\"AggregationwithHavingClause\"><\/a><\/p>\n<h3>&#8216;Having&#8217; with Aggregate Function<\/h3>\n<p>Having clause is the <strong>condition<\/strong>\u00a0applied to each of the <strong>groups<\/strong> formed by the &#8216;group by&#8217; clause. If the formed <strong>groups<\/strong> do not satisfy the <strong>condition<\/strong> then they are removed from the result.<\/p>\n<p><strong>Example of &#8216;Having&#8217; Aggregate Function:<\/strong><\/p>\n<p>If we want the department names whose total salary of instructors is greater the 72000. Then the query would be:<\/p>\n<p style=\"text-align: center\"><strong>select<\/strong> dept_name <strong>sum<\/strong>(salary) <strong>as<\/strong> sum_salary<br \/>\n<strong>from<\/strong> instructor<br \/>\n<strong>group by<\/strong> dept_name<br \/>\n<strong>having<\/strong> <strong>sum<\/strong>(salary)&gt;72000;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-860 size-full\" src=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/having-by-clause-1.jpg\" alt=\"having by clause 1\" width=\"496\" height=\"245\" srcset=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/having-by-clause-1.jpg 496w, https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/having-by-clause-1-300x148.jpg 300w\" sizes=\"auto, (max-width: 496px) 100vw, 496px\" \/><\/p>\n<p><a name=\"KeyTakeaways\"><\/a><\/p>\n<div id=\"keytake\">\n<h3>Key Takeaways:<\/h3>\n<ul>\n<li>Aggregate functions are applied to the <strong>set of tuple values<\/strong>. And they return a relation with a <strong>single attribute<\/strong> consisting of a <strong>single tuple<\/strong>.<\/li>\n<li>We have five aggregate functions <strong>count, average, maximum, minimum<\/strong> and <strong>sum.<\/strong><\/li>\n<li>The average and sum functions operate only on <strong>numerical values<\/strong>. The other aggregate function can also operate on <strong>non-numerical values<\/strong>.<\/li>\n<li>All aggregate functions avoid null values while operating except <strong>count(*)<\/strong>.<\/li>\n<li>Aggregate functions can also be used along with, the &#8216;<strong>group by<\/strong>&#8216; clause and &#8216;<strong>having<\/strong>&#8216; clause.<\/li>\n<\/ul>\n<p>So this was all about the aggregate functions in SQL. Always apply the sum and average function to the attribute with numerical values.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Aggregate functions in SQL evaluate the set of values and return a single value as a result. SQL has five aggregate functions count, average, maximum, minimum, sum. The aggregate functions, &#8216;sum&#8217; and &#8216;average&#8217; operate only on numeric values. While count, maximum, minimum can also operate on non-numeric data such as string. In this section, we [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[4],"tags":[],"class_list":{"0":"post-824","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-dbms","7":"entry"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What are Aggregate Functions in SQL? count, avg, max, min, sum, group by &amp; having - Binary Terms<\/title>\n<meta name=\"description\" content=\"Aggregate functions in SQL evaluates the set of tuple values and returns a relation with a single attribute carrying single tuple value as a result.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What are Aggregate Functions in SQL? count, avg, max, min, sum, group by &amp; having - Binary Terms\" \/>\n<meta property=\"og:description\" content=\"Aggregate functions in SQL evaluates the set of tuple values and returns a relation with a single attribute carrying single tuple value as a result.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html\" \/>\n<meta property=\"og:site_name\" content=\"Binary Terms\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-05T09:11:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-14T09:44:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg\" \/>\n<meta name=\"author\" content=\"Neha T\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Neha T\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#article\",\"isPartOf\":{\"@id\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html\"},\"author\":{\"name\":\"Neha T\",\"@id\":\"https:\/\/binaryterms.com\/#\/schema\/person\/e495f1d57f5c0a4c521cc3dba95661fe\"},\"headline\":\"Aggregate Functions in SQL\",\"datePublished\":\"2019-12-05T09:11:58+00:00\",\"dateModified\":\"2022-02-14T09:44:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html\"},\"wordCount\":1200,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/binaryterms.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg\",\"articleSection\":[\"DBMS\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html\",\"url\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html\",\"name\":\"What are Aggregate Functions in SQL? count, avg, max, min, sum, group by & having - Binary Terms\",\"isPartOf\":{\"@id\":\"https:\/\/binaryterms.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#primaryimage\"},\"image\":{\"@id\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg\",\"datePublished\":\"2019-12-05T09:11:58+00:00\",\"dateModified\":\"2022-02-14T09:44:13+00:00\",\"description\":\"Aggregate functions in SQL evaluates the set of tuple values and returns a relation with a single attribute carrying single tuple value as a result.\",\"breadcrumb\":{\"@id\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#primaryimage\",\"url\":\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg\",\"contentUrl\":\"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg\",\"width\":510,\"height\":470,\"caption\":\"teaches relation\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/binaryterms.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Aggregate Functions in SQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/binaryterms.com\/#website\",\"url\":\"https:\/\/binaryterms.com\/\",\"name\":\"Binary Terms\",\"description\":\"The Computer Science &amp; IT Guide\",\"publisher\":{\"@id\":\"https:\/\/binaryterms.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/binaryterms.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/binaryterms.com\/#organization\",\"name\":\"Binary Terms\",\"url\":\"https:\/\/binaryterms.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/binaryterms.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/binaryterms.com\/wp-content\/uploads\/2020\/05\/binary-terms-logo1.png\",\"contentUrl\":\"https:\/\/binaryterms.com\/wp-content\/uploads\/2020\/05\/binary-terms-logo1.png\",\"width\":400,\"height\":63,\"caption\":\"Binary Terms\"},\"image\":{\"@id\":\"https:\/\/binaryterms.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/binaryterms.com\/#\/schema\/person\/e495f1d57f5c0a4c521cc3dba95661fe\",\"name\":\"Neha T\",\"url\":\"https:\/\/binaryterms.com\/author\/author\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What are Aggregate Functions in SQL? count, avg, max, min, sum, group by & having - Binary Terms","description":"Aggregate functions in SQL evaluates the set of tuple values and returns a relation with a single attribute carrying single tuple value as a result.","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:\/\/binaryterms.com\/aggregate-functions-in-sql.html","og_locale":"en_GB","og_type":"article","og_title":"What are Aggregate Functions in SQL? count, avg, max, min, sum, group by & having - Binary Terms","og_description":"Aggregate functions in SQL evaluates the set of tuple values and returns a relation with a single attribute carrying single tuple value as a result.","og_url":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html","og_site_name":"Binary Terms","article_published_time":"2019-12-05T09:11:58+00:00","article_modified_time":"2022-02-14T09:44:13+00:00","og_image":[{"url":"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg","type":"","width":"","height":""}],"author":"Neha T","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Neha T","Estimated reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#article","isPartOf":{"@id":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html"},"author":{"name":"Neha T","@id":"https:\/\/binaryterms.com\/#\/schema\/person\/e495f1d57f5c0a4c521cc3dba95661fe"},"headline":"Aggregate Functions in SQL","datePublished":"2019-12-05T09:11:58+00:00","dateModified":"2022-02-14T09:44:13+00:00","mainEntityOfPage":{"@id":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html"},"wordCount":1200,"commentCount":0,"publisher":{"@id":"https:\/\/binaryterms.com\/#organization"},"image":{"@id":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#primaryimage"},"thumbnailUrl":"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg","articleSection":["DBMS"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html","url":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html","name":"What are Aggregate Functions in SQL? count, avg, max, min, sum, group by & having - Binary Terms","isPartOf":{"@id":"https:\/\/binaryterms.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#primaryimage"},"image":{"@id":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#primaryimage"},"thumbnailUrl":"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg","datePublished":"2019-12-05T09:11:58+00:00","dateModified":"2022-02-14T09:44:13+00:00","description":"Aggregate functions in SQL evaluates the set of tuple values and returns a relation with a single attribute carrying single tuple value as a result.","breadcrumb":{"@id":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/binaryterms.com\/aggregate-functions-in-sql.html"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#primaryimage","url":"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg","contentUrl":"https:\/\/binaryterms.com\/wp-content\/uploads\/2019\/12\/teaches-relation.jpg","width":510,"height":470,"caption":"teaches relation"},{"@type":"BreadcrumbList","@id":"https:\/\/binaryterms.com\/aggregate-functions-in-sql.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/binaryterms.com\/"},{"@type":"ListItem","position":2,"name":"Aggregate Functions in SQL"}]},{"@type":"WebSite","@id":"https:\/\/binaryterms.com\/#website","url":"https:\/\/binaryterms.com\/","name":"Binary Terms","description":"The Computer Science &amp; IT Guide","publisher":{"@id":"https:\/\/binaryterms.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/binaryterms.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/binaryterms.com\/#organization","name":"Binary Terms","url":"https:\/\/binaryterms.com\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/binaryterms.com\/#\/schema\/logo\/image\/","url":"https:\/\/binaryterms.com\/wp-content\/uploads\/2020\/05\/binary-terms-logo1.png","contentUrl":"https:\/\/binaryterms.com\/wp-content\/uploads\/2020\/05\/binary-terms-logo1.png","width":400,"height":63,"caption":"Binary Terms"},"image":{"@id":"https:\/\/binaryterms.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/binaryterms.com\/#\/schema\/person\/e495f1d57f5c0a4c521cc3dba95661fe","name":"Neha T","url":"https:\/\/binaryterms.com\/author\/author"}]}},"_links":{"self":[{"href":"https:\/\/binaryterms.com\/wp-json\/wp\/v2\/posts\/824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/binaryterms.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/binaryterms.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/binaryterms.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/binaryterms.com\/wp-json\/wp\/v2\/comments?post=824"}],"version-history":[{"count":12,"href":"https:\/\/binaryterms.com\/wp-json\/wp\/v2\/posts\/824\/revisions"}],"predecessor-version":[{"id":3386,"href":"https:\/\/binaryterms.com\/wp-json\/wp\/v2\/posts\/824\/revisions\/3386"}],"wp:attachment":[{"href":"https:\/\/binaryterms.com\/wp-json\/wp\/v2\/media?parent=824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/binaryterms.com\/wp-json\/wp\/v2\/categories?post=824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/binaryterms.com\/wp-json\/wp\/v2\/tags?post=824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}