<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4085,"date":"2022-04-04T11:28:07","date_gmt":"2022-04-04T11:28:07","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4085"},"modified":"2022-04-04T11:28:07","modified_gmt":"2022-04-04T11:28:07","slug":"what-are-the-aggregate-functions-of-mongodb","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/","title":{"rendered":"What are the aggregate functions of MongoDB ?"},"content":{"rendered":"<ul>\n<li style=\"text-align: justify;\">The aggregation pipeline consists of stages, and each stage transforms the document in MongoDB.<\/li>\n<li style=\"text-align: justify;\">In each state, the documents are taken as input and produce the resultant set of documents are now in the next stage (id available) the resultant documents taken as input and produce output, this process is going on till the last stage.<\/li>\n<li style=\"text-align: justify;\">In other word, the aggregation pipeline is a multi-stage pipeline.<\/li>\n<li style=\"text-align: justify;\">The basic pipeline stages provide filters that will perform like queries and the document transformation modifies the resultant document, and the other pipeline provides tools for grouping and sorting documents.<\/li>\n<li style=\"text-align: justify;\">In aggregation, there are various functions used:<\/li>\n<\/ul>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4086 aligncenter\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb.png\" alt=\"\" width=\"1110\" height=\"716\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb.png 1110w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb-300x194.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb-1024x661.png 1024w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb-768x495.png 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb-390x252.png 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb-820x529.png 820w\" sizes=\"(max-width: 1110px) 100vw, 1110px\" \/><\/p>\n<h4 id=\"sum\" style=\"text-align: justify;\">Sum :<\/h4>\n<ul style=\"text-align: justify;\">\n<li>This aggregation function is used to sum numeric values for the document in each group.<\/li>\n<\/ul>\n<h4 id=\"count\" style=\"text-align: justify;\">Count :<\/h4>\n<ul style=\"text-align: justify;\">\n<li>This aggregation function is used to count total number of documents.<\/li>\n<\/ul>\n<h4 id=\"average\" style=\"text-align: justify;\">Average :<\/h4>\n<ul style=\"text-align: justify;\">\n<li>This aggregation function is used to calculates the average of all given values from all documents.<\/li>\n<\/ul>\n<h4 id=\"minimum\" style=\"text-align: justify;\">Minimum :<\/h4>\n<ul style=\"text-align: justify;\">\n<li>This aggregation function is used to get the minimum value from all the documents.<\/li>\n<\/ul>\n<h4 id=\"maximum\" style=\"text-align: justify;\">Maximum :<\/h4>\n<ul style=\"text-align: justify;\">\n<li>This aggregation function is used to get the maximum value from all the documents.<\/li>\n<\/ul>\n<h4 id=\"first\" style=\"text-align: justify;\">First :<\/h4>\n<ul style=\"text-align: justify;\">\n<li>This aggregation function is used to get the first document from the grouping.<\/li>\n<\/ul>\n<h4 id=\"last\" style=\"text-align: justify;\">Last :<\/h4>\n<ul>\n<li style=\"text-align: justify;\">This aggregation function is used to get the last document from the grouping.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The aggregation pipeline consists of stages, and each stage transforms the document in MongoDB. In each state, the documents are taken as input and produce the resultant set of documents are now in the next stage (id available) the resultant documents taken as input and produce output, this process is going on till the last [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[16831],"tags":[16894,16887,16889,16897,16893,16890,16892,16891,16888,16895,16896],"class_list":["post-4085","post","type-post","status-publish","format-standard","hentry","category-mongodb","tag-aggregate-function-in-mongodb-example","tag-aggregation-in-mongodb","tag-aggregation-operations","tag-aggregation-pipeline-in-mongodb","tag-aggregations-in-mongodb-by-example","tag-concept-of-aggregation-in-mongodb","tag-how-to-use-aggregations-in-mongodb","tag-mongodb-aggregate-functions","tag-mongodb-aggregation","tag-mongodb-aggregation-operators","tag-mongodb-aggregation-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What are the aggregate functions of MongoDB ? - Wikitechy<\/title>\n<meta name=\"description\" content=\"What are the aggregate functions of MongoDB ? - The aggregation pipeline consists of stages, and each stage transforms the document in MongoDB.\" \/>\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.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What are the aggregate functions of MongoDB ? - Wikitechy\" \/>\n<meta property=\"og:description\" content=\"What are the aggregate functions of MongoDB ? - The aggregation pipeline consists of stages, and each stage transforms the document in MongoDB.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-04T11:28:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/\",\"name\":\"What are the aggregate functions of MongoDB ? - Wikitechy\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb.png\",\"datePublished\":\"2022-04-04T11:28:07+00:00\",\"dateModified\":\"2022-04-04T11:28:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What are the aggregate functions of MongoDB ? - The aggregation pipeline consists of stages, and each stage transforms the document in MongoDB.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb.png\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb.png\",\"width\":1110,\"height\":716},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What are the aggregate functions of MongoDB ? - Wikitechy","description":"What are the aggregate functions of MongoDB ? - The aggregation pipeline consists of stages, and each stage transforms the document in MongoDB.","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.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/","og_locale":"en_US","og_type":"article","og_title":"What are the aggregate functions of MongoDB ? - Wikitechy","og_description":"What are the aggregate functions of MongoDB ? - The aggregation pipeline consists of stages, and each stage transforms the document in MongoDB.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/","og_site_name":"Wikitechy","article_published_time":"2022-04-04T11:28:07+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb.png"}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/","name":"What are the aggregate functions of MongoDB ? - Wikitechy","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb.png","datePublished":"2022-04-04T11:28:07+00:00","dateModified":"2022-04-04T11:28:07+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What are the aggregate functions of MongoDB ? - The aggregation pipeline consists of stages, and each stage transforms the document in MongoDB.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-aggregate-functions-of-mongodb\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/aggregation-functions-mongodb.png","width":1110,"height":716},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4085"}],"version-history":[{"count":1,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4085\/revisions"}],"predecessor-version":[{"id":4088,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4085\/revisions\/4088"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}