{"id":43726,"date":"2023-08-25T14:42:28","date_gmt":"2023-08-25T12:42:28","guid":{"rendered":"https:\/\/blog.sheetgo.com\/?p=43726"},"modified":"2025-12-17T18:44:10","modified_gmt":"2025-12-17T17:44:10","slug":"como-usar-as-funcoes-agregadas-do-bigquery","status":"publish","type":"post","link":"https:\/\/www.sheetgo.com\/pt\/blog\/data-science\/how-to-use-bigquery-aggregate-functions\/","title":{"rendered":"Como usar as fun\u00e7\u00f5es agregadas do BigQuery"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221; da_is_popup=&#8221;off&#8221; da_exit_intent=&#8221;off&#8221; da_has_close=&#8221;on&#8221; da_alt_close=&#8221;off&#8221; da_dark_close=&#8221;off&#8221; da_not_modal=&#8221;on&#8221; da_is_singular=&#8221;off&#8221; da_with_loader=&#8221;off&#8221; da_has_shadow=&#8221;on&#8221; da_disable_devices=&#8221;off|off|off&#8221;][et_pb_row _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_text module_id=&#8221;avg&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><span style=\"font-weight: 400;\">How to use BigQuery aggregate functions<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Analyzing large datasets to gain insights can be a daunting task. With terabytes or even petabytes of data, manually reviewing rows and columns is impossible. This is where <\/span><a href=\"https:\/\/cloud.google.com\/bigquery\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">BigQuery<\/span><\/a><span style=\"font-weight: 400;\"> aggregate functions come in handy.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">BigQuery is Google&#8217;s fully managed enterprise data warehouse that allows you to run fast queries on large datasets. One of the greatest benefits of BigQuery is its ability to aggregate data &#8211; combining information from multiple rows to help you gain insights.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">With these functions, you can easily summarize and analyze large amounts of data.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this article, you&#8217;ll learn everything you need to start using simple functions such as COUNT, SUM, AVG, MIN and MAX.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;aggregate&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><span style=\"font-weight: 400;\">What are aggregate functions in BigQuery?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Aggregate functions are an essential component of BigQuery. These powerful functions enable you to derive meaningful insights from large datasets by performing calculations across multiple rows of data.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">With aggregate functions, you can combine multiple rows of data into a single result or output. Some examples include calculating totals, averages, maximums or minimums across a range of data.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Whether you need to sum revenue over time, find the average order value, or count the number of clients &#8211; aggregate functions have you covered. Here are some examples of these functions.<\/span><\/p>\n<p><b>AVG<\/b><span style=\"font-weight: 400;\">: returns the average of all non-null values.<\/span><\/p>\n<p><b>COUNT<\/b><span style=\"font-weight: 400;\">: returns the total number of rows.<\/span><\/p>\n<p><b>COUNTIF<\/b><span style=\"font-weight: 400;\">: returns the number of rows that meet a specified condition.<\/span><\/p>\n<p><b>MAX<\/b><span style=\"font-weight: 400;\">: returns the maximum non-null value.<\/span><\/p>\n<p><b>MIN<\/b><span style=\"font-weight: 400;\">: returns the minimum non-null value.<\/span><\/p>\n<p><b>SUM<\/b><span style=\"font-weight: 400;\">: returns the sum of all non-null values.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s take a look at these aggregate functions and learn how to make the most of them. We&#8217;ll use this public dataset containing information about all the world population divided by country, from the year 1960 onwards.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/08\/BigQuery-aggregate-functions-1.png&#8221; title_text=&#8221;BigQuery aggregate functions 1&#8243; align=&#8221;center&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text module_id=&#8221;AVG&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><span style=\"font-weight: 400;\">BigQuery aggregate functions: AVG<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Let&#8217;s start with the AVG function. This function will return the average of all non-null values. Here&#8217;s the syntax:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT AVG(column)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM table_name;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">I&#8217;ll write a query to calculate the average of the population of these 6 countries in 2000: China, Germany, Russia, Japan, India, Brazil.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT AVG(year_2000)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM `bigquery-public-data.world_bank_global_population.population_by_country`<\/span><\/p>\n<p><span style=\"font-weight: 400;\">WHERE country IN (&#8216;China&#8217;, &#8216;Germany&#8217;, &#8216;Russia&#8217;, &#8216;Japan&#8217;, &#8216;India&#8217;, &#8216;Brazil&#8217;)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">LIMIT 100;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s break this formula down:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">SELECT AVG(year_2000) \u2013 This statement specifies that we want to calculate the average of the specified column.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM `bigquery-public-data.world_bank_global_population.population_by_country` \u2013 This specifies the table we are querying.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">WHERE country IN (&#8216;China&#8217;, &#8216;Germany&#8217;, &#8216;Russia&#8217;, &#8216;Japan&#8217;, &#8216;India&#8217;, &#8216;Brazil&#8217;)<\/span><span style=\"font-weight: 400;\">\u00a0\u2013 This WHERE clause filters the rows to only those countries in parentheses.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/08\/BigQuery-aggregate-functions-2.png&#8221; alt=&#8221;BigQuery aggregate functions 2<br \/>\n&#8221; title_text=&#8221;BigQuery aggregate functions 2&#8243; align=&#8221;center&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">When we run the query, BigQuery returns the average of the population of these 6 countries.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;count&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><span style=\"font-weight: 400;\">BigQuery aggregate functions: COUNT<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Now we&#8217;ll take a closer look at the COUNT function. When we run this function, BigQuery returns the total number of rows. Here&#8217;s the syntax we&#8217;ll use:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT COUNT(column)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM table_name;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">I&#8217;ll run a simple query to count the number of rows contained in the table. We&#8217;ll use the &#8220;country&#8221; column as a reference.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT COUNT(country)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM `bigquery-public-data.world_bank_global_population.population_by_country`<\/span><\/p>\n<p><span style=\"font-weight: 400;\">LIMIT 100;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/08\/BigQuery-aggregate-functions-3.png&#8221; alt=&#8221;BigQuery aggregate functions 3&#8243; title_text=&#8221;BigQuery aggregate functions 3&#8243; align=&#8221;center&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">After running this query, BigQuery has returned the number of rows: 264.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;countif&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><span style=\"font-weight: 400;\">BigQuery aggregate functions: COUNTIF<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">With the COUNTIF function, BigQuery will return the number of rows that meet a certain condition. Here&#8217;s the syntax:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT COUNTIF(condition)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM table_name;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s say I want BigQuery to return the number of rows where the population is less than 100.000 in a specific year. I&#8217;ll write the query specifying the condition: column year_2000 is less than 100.000.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This is what the query would look like:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT COUNTIF(year_2000&lt;100000)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM `bigquery-public-data.world_bank_global_population.population_by_country`<\/span><\/p>\n<p><span style=\"font-weight: 400;\">LIMIT 100;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/08\/BigQuery-aggregate-functions-4.png&#8221; alt=&#8221;BigQuery aggregate functions 4&#8243; title_text=&#8221;BigQuery aggregate functions 4&#8243; align=&#8221;center&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">When I execute this query, BigQuery returns the number of rows that meet this condition: 27.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;max&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><span style=\"font-weight: 400;\">BigQuery aggregate functions: MAX<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">By using the MAX function, I can ask BigQuery to return the maximum non-null value in a specific column. This is the syntax we&#8217;ll use.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT MAX(column)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM table_name;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">I&#8217;ll write a query that will return the maximum value contained in the year_2000 column. In addition, I&#8217;ll add a WHERE clause to restrict the query to these 6 countries: China, Germany, Russia, Japan, India, Brazil.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT MAX(year_2000)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM `bigquery-public-data.world_bank_global_population.population_by_country`<\/span><\/p>\n<p><span style=\"font-weight: 400;\">WHERE country IN (&#8216;China&#8217;,&#8217;Germany&#8217;,&#8217;Russia&#8217;,&#8217;Japan&#8217;, &#8216;India&#8217;, &#8216;Brazil&#8217;)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">LIMIT 100;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/08\/BigQuery-aggregate-functions-5.png&#8221; alt=&#8221;BigQuery aggregate functions 5&#8243; title_text=&#8221;BigQuery aggregate functions 5&#8243; align=&#8221;center&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">When I execute the query, it returns the maximum value within the specified range: 1,262,645,000.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;min&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><span style=\"font-weight: 400;\">BigQuery aggregate functions: MIN<\/span>\u00a0<\/h2>\n<p><span style=\"font-weight: 400;\">As opposed to the MAX function, the MIN function will return the minimum value in a column. This is what the syntax looks like.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT MIN(column)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM table_name;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">Now, I&#8217;ll just replace the MAX function with MIN.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT MIN(year_2000)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM `bigquery-public-data.world_bank_global_population.population_by_country`<\/span><\/p>\n<p><span style=\"font-weight: 400;\">WHERE country IN (&#8216;China&#8217;, &#8216;Germany&#8217;,&#8217;Russia&#8217;,&#8217;Japan&#8217;, &#8216;India&#8217;, &#8216;Brazil&#8217;)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">LIMIT 100;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/08\/BigQuery-aggregate-functions-8.png&#8221; alt=&#8221;BigQuery aggregate functions 7&#8243; title_text=&#8221;BigQuery aggregate functions 8&#8243; align=&#8221;center&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">BigQuery has just returned the minimum value. The smallest population is north of 82 million.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;sum&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><span style=\"font-weight: 400;\">BigQuery aggregate functions: SUM<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Lastly, we&#8217;ll take a closer look at the SUM function. By using this function, I&#8217;ll ask BigQuery to calculate the sum of all the values.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT SUM(column)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM table_name;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">Here, I&#8217;ll write a query to calculate the sum of the population of the same 6 countries.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.21.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">SELECT SUM(year_2000)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM `bigquery-public-data.world_bank_global_population.population_by_country`<\/span><\/p>\n<p><span style=\"font-weight: 400;\">WHERE country IN (&#8216;China&#8217;, &#8216;Germany&#8217;,&#8217;Russia&#8217;,&#8217;Japan&#8217;, &#8216;India&#8217;, &#8216;Brazil&#8217;)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">LIMIT 100;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/08\/BigQuery-aggregate-functions-7.png&#8221; alt=&#8221;BigQuery aggregate functions 6&#8243; title_text=&#8221;BigQuery aggregate functions 7&#8243; align=&#8221;center&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">As a result, BigQuery has calculated the population of these 6 countries: over 2.7 billion.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;use&#8221; _builder_version=&#8221;4.21.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><span style=\"font-weight: 400;\">How to use BigQuery aggregate functions<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">There you have it! That&#8217;s how you can use aggregate functions in BigQuery. By using these functions, you can combine and summarize data from multiple rows into a single value. If you want to combine tables instead, check out this article on how to use <\/span><a href=\"https:\/\/www.sheetgo.com\/blog\/integrations\/bigquery-joins-a-step-by-step-guide\/\"><span style=\"font-weight: 400;\">BigQuery joins<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to use BigQuery aggregate functions Analyzing large datasets to gain insights can be a daunting task. With terabytes or even petabytes of data, manually reviewing rows and columns is impossible. This is where BigQuery aggregate functions come in handy. BigQuery is Google&#8217;s fully managed enterprise data warehouse that allows you to run fast queries [&hellip;]<\/p>\n","protected":false},"author":42,"featured_media":43848,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[31],"tags":[],"class_list":["post-43726","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-science"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/posts\/43726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/comments?post=43726"}],"version-history":[{"count":0,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/posts\/43726\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/media\/43848"}],"wp:attachment":[{"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/media?parent=43726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/categories?post=43726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/tags?post=43726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}