{"id":8847,"date":"2020-06-15T11:00:24","date_gmt":"2020-06-15T02:00:24","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=8847"},"modified":"2020-06-12T19:06:44","modified_gmt":"2020-06-12T10:06:44","slug":"common-aggregate-functions-in-sql","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/8847","title":{"rendered":"Common Aggregate Functions in SQL"},"content":{"rendered":"\n<p>Today I will talk about some common aggregate functions that are widely used in SQL programming language.<\/p>\n\n\n\n<h4><strong>Count<\/strong><\/h4>\n\n\n\n<p>if we want to get the count of all records or specific where condition records, we can get by using <strong>count<\/strong> function.<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT COUNT(column_name) FROM table_name\ufeff\nSELECT COUNT(column_name) FROM table_name WHERE condition;<\/code><\/pre>\n\n\n\n<h4><strong>AVG<\/strong><\/h4>\n\n\n\n<p>For average rate calculations, we can use this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT AVG(column_name) FROM table_name;\nSELECT AVG(column_name) FROM table_name WHERE condition;<\/code><\/pre>\n\n\n\n<h4><strong>SUM<\/strong><\/h4>\n\n\n\n<p>For sum results of all records, we can use this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT SUM(column_name) FROM table_name\ufeff \nSELECT SUM(column_name) FROM table_name\ufeff WHERE condition;<\/code><\/pre>\n\n\n\n<h4><strong>MIN<\/strong><\/h4>\n\n\n\n<p>For specific minimum result of a column, we can use this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT MIN(column_name) FROM table_name;\nSELECT MIN(column_name) FROM table_name WHERE condition;<\/code><\/pre>\n\n\n\n<p>Likewise min, we can use <strong>max<\/strong> to get maximum result.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT MAX(column_name) FROM table_name;\nSELECT MAX(column_name) FROM table_name WHERE condition;<\/code><\/pre>\n\n\n\n<p>By Yuuma<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/8847\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/8847\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Common Aggregate Functions in SQL\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/8847\" data-text=\"Common Aggregate Functions in SQL\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/8847\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/8847\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>Today I will talk about some common aggregate functions that are widely used in SQL programming language. Coun [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/8847"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=8847"}],"version-history":[{"count":3,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/8847\/revisions"}],"predecessor-version":[{"id":8851,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/8847\/revisions\/8851"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=8847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=8847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=8847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}