How to Use GROUP BY, HAVING, and ORDER BY SQL Clauses – dummies

{“appState”:{“pageLoadApiCallsStatus”:true},”articleState”:{“article”:{“headers”:{“creationTime”:”2016-03-26T14:00:40+00:00″,”modifiedTime”:”2022-01-18T19:15:24+00:00″,”timestamp”:”2022-09-14T18:19:01+00:00″},”data”:{“breadcrumbs”:[{“name”:”Technology”,”_links”:{“self”:”https://dummies-api.dummies.com/v2/categories/33512″},”slug”:”technology”,”categoryId”:33512},{“name”:”Programming & Web Design”,”_links”:{“self”:”https://dummies-api.dummies.com/v2/categories/33592″},”slug”:”programming-web-design”,”categoryId”:33592},{“name”:”SQL”,”_links”:{“self”:”https://dummies-api.dummies.com/v2/categories/33608″},”slug”:”sql”,”categoryId”:33608}],”title”:”How to Use GROUP BY, HAVING, and ORDER BY SQL Clauses”,”strippedTitle”:”how to use group by, having, and order by sql clauses”,”slug”:”how-to-use-group-by-having-and-order-by-sql-clauses”,”canonicalUrl”:””,”seo”:{“metaDescription”:”SQL gives you options for retrieving, analyzing, and displaying the information you need with the GROUP BY, HAVING, and ORDER BY clauses. Here are some examples”,”noIndex”:0,”noFollow”:0},”content”:”SQL gives you options for retrieving, analyzing, and displaying the information you need with the GROUP BY, HAVING, and ORDER BY clauses. Here are some examples of how you can use them.\r\n<h2 id=\”tab1\” >GROUP BY clauses</h2>\r\nSometimes, rather than retrieving individual records, you want to know something about a group of records. The <span class=\”code\”>GROUP BY</span> clause is the tool you need.\r\n\r\nSuppose you’re the sales manager of another location, and you want to look at the performance of your sales force. If you do a simple <span class=\”code\”>SELECT</span>, such as the following query:\r\n<pre class=\”code\”>SELECT InvoiceNo, SaleDate, Salesperson, TotalSale\r\n FROM SALES;</pre>\r\n<img src=\”https://www.dummies.com/wp-content/uploads/SQLFDFigure101.jpg\” alt=\”\” width=\”630\” height=\”414\” />\r\n\r\nThis result gives you some idea of how well your salespeople are doing because so few total sales are involved. However, in real life, a company would have many more sales — and it wouldn’t be so easy to tell whether sales objectives were being met.\r\n\r\nTo do the real analysis, you can combine the <span class=\”code\”>GROUP BY</span> clause with one of the <i>aggregate </i>functions (also called <i>set functions</i>) to get a quantitative picture of sales performance. For example, you can see which salesperson is selling more of the profitable high-ticket items by using the average (<span class=\”code\”>AVG</span>) function as follows:\r\n<pre class=\”code\”>SELECT Salesperson, AVG(TotalSale)\r\n FROM SALES\r\n GROUP BY Salesperson;</pre>\r\nRunning the query with a different database management system would retrieve the same result, but might appear a little different.\r\n\r\n<img src=\”https://www.dummies.com/wp-content/uploads/SQLFDFigure102.jpg\” alt=\”\” width=\”630\” height=\”412\” />\r\n\r\nThe average value of Bennett’s sales is considerably higher than that of the other two salespeople. You compare total sales with a similar query:\r\n<pre class=\”code\”>SELECT Salesperson, SUM(TotalSale)\r\n FROM SALES\r\n GROUP BY Salesperson;</pre>\r\n<img src=\”https://www.dummies.com/wp-content/uploads/SQLFDFigure103.jpg\” alt=\”\” width=\”630\” height=\”412\” />\r\n\r\nBennett also has the highest total sales, which is consistent with having the highest average sales.\r\n<h2 id=\”tab2\” >HAVING clauses</h2>\r\nYou can analyze the grouped data further by using the <span class=\”code\”>HAVING</span> clause. The <span class=\”code\”>HAVING</span> clause is a filter that acts similar to a <span class=\”code\”>WHERE</span> clause, but on groups of rows rather than on individual rows. To illustrate the function of the <span class=\”code\”>HAVING</span> clause, suppose the sales manager considers Bennett to be in a class by himself.\r\n\r\nHis performance distorts the overall data for the other salespeople. (Aha — a curve-wrecker.) You can exclude Bennett’s sales from the grouped data by using a <span class=\”code\”>HAVING</span> clause as follows:\r\n<pre class=\”code\”>SELECT Salesperson, SUM(TotalSale)\r\n FROM SALES\r\n GROUP BY Salesperson\r\n HAVING Salesperson &lt;&gt;’Bennett’;</pre>\r\nOnly rows where the salesperson is not Bennett are considered.\r\n\r\n<img src=\”https://www.dummies.com/wp-content/uploads/SQLFDFigure104.jpg\” alt=\”\” width=\”630\” height=\”412\” />\r\n<h2 id=\”tab3\” >ORDER BY clauses</h2>\r\nUse the <span class=\”code\”>ORDER BY</span> clause to display the output table of a query in either ascending or descending alphabetical order. Whereas the <span class=\”code\”>GROUP BY</span> clause gathers rows into groups and sorts the groups into alphabetical order, <span class=\”code\”>ORDER BY</span> sorts individual rows. The <span class=\”code\”>ORDER BY</span> clause must be the last clause that you specify in a query.\r\n\r\nIf the query also contains a <span class=\”code\”>GROUP BY</span> clause, the clause first arranges the output rows into groups. The <span class=\”code\”>ORDER BY</span> clause then sorts the rows within each group. If you have no <span class=\”code\”>GROUP BY</span> clause, then the statement considers the entire table as a group, and the <span class=\”code\”>ORDER BY</span> clause sorts all its rows according to the column (or columns) that the <span class=\”code\”>ORDER BY</span> clause specifies.\r\n\r\nTo illustrate this point, consider the data in the SALES table. The SALES table contains columns for <span class=\”code\”>InvoiceNo</span>, <span class=\”code\”>SaleDate</span>, <span class=\”code\”>Salesperson</span>, and <span class=\”code\”>TotalSale</span>. If you use the following example, you see all the data in the SALES table — but in an arbitrary order:\r\n<pre class=\”code\”>SELECT * FROM SALES ;</pre>\r\nIn one implementation, this may be the order in which you inserted the rows in the table; in another implementation, the order may be that of the most recent updates. The order can also change unexpectedly if anyone physically reorganizes the database. That’s one reason it’s usually a good idea to specify the order in which you want the rows.\r\n\r\nYou may, for example, want to see the rows in order by the <span class=\”code\”>SaleDate</span> like this:\r\n<pre class=\”code\”>SELECT * FROM SALES ORDER BY SaleDate ;</pre>\r\nThis example returns all the rows in the SALES table in order by <span class=\”code\”>SaleDate</span>.\r\nFor rows with the same <span class=\”code\”>SaleDate</span>, the default order depends on the implementation. You can, however, specify how to sort the rows that share the same <span class=\”code\”>SaleDate</span>. You may want to see the sales for each <span class=\”code\”>SaleDate</span> in order by <span class=\”code\”>InvoiceNo</span>, as follows:\r\n<pre class=\”code\”>SELECT * FROM SALES ORDER BY SaleDate, InvoiceNo ;</pre>\r\nThis example first orders the sales by <span class=\”code\”>SaleDate</span>; then for each <span class=\”code\”>SaleDate</span>, it orders the sales by <span class=\”code\”>InvoiceNo</span>. But don’t confuse that example with the following query:\r\n<pre class=\”code\”>SELECT * FROM SALES ORDER BY InvoiceNo, SaleDate ;</pre>\r\nThis query first orders the sales by <span class=\”code\”>INVOICE_NO</span>. Then for each different <span class=\”code\”>InvoiceNo</span>, the query orders the sales by <span class=\”code\”>SaleDate</span>. This probably won’t yield the result you want, because it’s unlikely that multiple sale dates will exist for a single invoice number.\r\n\r\nThe following query is another example of how SQL can return data:\r\n<pre class=\”code\”>SELECT * FROM SALES ORDER BY Salesperson, SaleDate ;</pre>\r\nThis example first orders by <span class=\”code\”>Salesperson</span> and then by <span class=\”code\”>SaleDate</span>. After you look at the data in that order, you may want to invert it, as follows:\r\n<pre class=\”code\”>SELECT * FROM SALES ORDER BY SaleDate, Salesperson ;</pre>\r\nThis example orders the rows first by <span class=\”code\”>SaleDate</span> and then by <span class=\”code\”>Salesperson</span>.\r\n\r\nAll these ordering examples are in ascending (<span class=\”code\”>ASC</span>) order, which is the default sort order. The last <span class=\”code\”>SELECT</span> shows earlier sales first — and, within a given date, shows sales for <span class=\”code\”>‘Adams’</span> before <span class=\”code\”>‘Baker’</span>. If you prefer descending (<span class=\”code\”>DESC</span>) order, you can specify this order for one or more of the order columns, as follows:\r\n<pre class=\”code\”>SELECT * FROM SALES\r\nORDER BY SaleDate DESC, Salesperson ASC ;</pre>\r\nThis example specifies a descending order for sale dates, showing the more recent sales first, and an ascending order for salespeople, putting them in alphabetical order. That should give you a better picture of how Bennett’s performance stacks up against that of the other salespeople.”,”description”:”SQL gives you options for retrieving, analyzing, and displaying the information you need with the GROUP BY, HAVING, and ORDER BY clauses. Here are some examples of how you can use them.\r\n<h2 id=\”tab1\” >GROUP BY clauses</h2>\r\nSometimes, rather than retrieving individual records, you want to know something about a group of records. The <span class=\”code\”>GROUP BY</span> clause is the tool you need.\r\n\r\nSuppose you’re the sales manager of another location, and you want to look at the performance of your sales force. If you do a simple <span class=\”code\”>SELECT</span>, such as the following query:\r\n<pre class=\”code\”>SELECT InvoiceNo, SaleDate, Salesperson, TotalSale\r\n FROM SALES;</pre>\r\n<img src=\”https://www.dummies.com/wp-content/uploads/SQLFDFigure101.jpg\” alt=\”\” width=\”630\” height=\”414\” />\r\n\r\nThis result gives you some idea of how well your salespeople are doing because so few total sales are involved. However, in real life, a company would have many more sales — and it wouldn’t be so easy to tell whether sales objectives were being met.\r\n\r\nTo do the real analysis, you can combine the <span class=\”code\”>GROUP BY</span> clause with one of the <i>aggregate </i>functions (also called <i>set functions</i>) to get a quantitative picture of sales performance. For example, you can see which salesperson is selling more of the profitable high-ticket items by using the average (<span class=\”code\”>AVG</span>) function as follows:\r\n<pre class=\”code\”>SELECT Salesperson, AVG(TotalSale)\r\n FROM SALES\r\n GROUP BY Salesperson;</pre>\r\nRunning the query with a different database management system would retrieve the same result, but might appear a little different.\r\n\r\n<img src=\”https://www.dummies.com/wp-content/uploads/SQLFDFigure102.jpg\” alt=\”\” width=\”630\” height=\”412\” />\r\n\r\nThe average value of Bennett’s sales is considerably higher than that of the other two salespeople. You compare total sales with a similar query:\r\n<pre class=\”code\”>SELECT Salesperson, SUM(TotalSale)\r\n FROM SALES\r\n GROUP BY Salesperson;</pre>\r\n<img src=\”https://www.dummies.com/wp-content/uploads/SQLFDFigure103.jpg\” alt=\”\” width=\”630\” height=\”412\” />\r\n\r\nBennett also has the highest total sales, which is consistent with having the highest average sales.\r\n<h2 id=\”tab2\” >HAVING clauses</h2>\r\nYou can analyze the grouped data further by using the <span class=\”code\”>HAVING</span> clause. The <span class=\”code\”>HAVING</span> clause is a filter that acts similar to a <span class=\”code\”>WHERE</span> clause, but on groups of rows rather than on individual rows. To illustrate the function of the <span class=\”code\”>HAVING</span> clause, suppose the sales manager considers Bennett to be in a class by himself.\r\n\r\nHis performance distorts the overall data for the other salespeople. (Aha — a curve-wrecker.) You can exclude Bennett’s sales from the grouped data by using a <span class=\”code\”>HAVING</span> clause as follows:\r\n<pre class=\”code\”>SELECT Salesperson, SUM(TotalSale)\r\n FROM SALES\r\n GROUP BY Salesperson\r\n HAVING Salesperson &lt;&gt;’Bennett’;</pre>\r\nOnly rows where the salesperson is not Bennett are considered.\r\n\r\n<img src=\”https://www.dummies.com/wp-content/uploads/SQLFDFigure104.jpg\” alt=\”\” width=\”630\” height=\”412\” />\r\n<h2 id=\”tab3\” >ORDER BY clauses</h2>\r\nUse the <span class=\”code\”>ORDER BY</span> clause to display the output table of a query in either ascending or descending alphabetical order. Whereas the <span class=\”code\”>GROUP BY</span> clause gathers rows into groups and sorts the groups into alphabetical order, <span class=\”code\”>ORDER BY</span> sorts individual rows. The <span class=\”code\”>ORDER BY</span> clause must be the last clause that you specify in a query.\r\n\r\nIf the query also contains a <span class=\”code\”>GROUP BY</span> clause, the clause first arranges the output rows into groups. The <span class=\”code\”>ORDER BY</span> clause then sorts the rows within each group. If you have no <span class=\”code\”>GROUP BY</span> clause, then the statement considers the entire table as a group, and the <span class=\”code\”>ORDER BY</span> clause sorts all its rows according to the column (or columns) that the <span class=\”code\”>ORDER BY</span> clause specifies.\r\n\r\nTo illustrate this point, consider the data in the SALES table. The SALES table contains columns for <span class=\”code\”>InvoiceNo</span>, <span class=\”code\”>SaleDate</span>, <span class=\”code\”>Salesperson</span>, and <span class=\”code\”>TotalSale</span>. If you use the following example, you see all the data in the SALES table — but in an arbitrary order:\r\n<pre class=\”code\”>SELECT * FROM SALES ;</pre>\r\nIn one implementation, this may be the order in which you inserted the rows in the table; in another implementation, the order may be that of the most recent updates. The order can also change unexpectedly if anyone physically reorganizes the database. That’s one reason it’s usually a good idea to specify the order in which you want the rows.\r\n\r\nYou may, for example, want to see the rows in order by the <span class=\”code\”>SaleDate</span> like this:\r\n<pre class=\”code\”>SELECT * FROM SALES ORDER BY SaleDate ;</pre>\r\nThis example returns all the rows in the SALES table in order by <span class=\”code\”>SaleDate</span>.\r\nFor rows with the same <span class=\”code\”>SaleDate</span>, the default order depends on the implementation. You can, however, specify how to sort the rows that share the same <span class=\”code\”>SaleDate</span>. You may want to see the sales for each <span class=\”code\”>SaleDate</span> in order by <span class=\”code\”>InvoiceNo</span>, as follows:\r\n<pre class=\”code\”>SELECT * FROM SALES ORDER BY SaleDate, InvoiceNo ;</pre>\r\nThis example first orders the sales by <span class=\”code\”>SaleDate</span>; then for each <span class=\”code\”>SaleDate</span>, it orders the sales by <span class=\”code\”>InvoiceNo</span>. But don’t confuse that example with the following query:\r\n<pre class=\”code\”>SELECT * FROM SALES ORDER BY InvoiceNo, SaleDate ;</pre>\r\nThis query first orders the sales by <span class=\”code\”>INVOICE_NO</span>. Then for each different <span class=\”code\”>InvoiceNo</span>, the query orders the sales by <span class=\”code\”>SaleDate</span>. This probably won’t yield the result you want, because it’s unlikely that multiple sale dates will exist for a single invoice number.\r\n\r\nThe following query is another example of how SQL can return data:\r\n<pre class=\”code\”>SELECT * FROM SALES ORDER BY Salesperson, SaleDate ;</pre>\r\nThis example first orders by <span class=\”code\”>Salesperson</span> and then by <span class=\”code\”>SaleDate</span>. After you look at the data in that order, you may want to invert it, as follows:\r\n<pre class=\”code\”>SELECT * FROM SALES ORDER BY SaleDate, Salesperson ;</pre>\r\nThis example orders the rows first by <span class=\”code\”>SaleDate</span> and then by <span class=\”code\”>Salesperson</span>.\r\n\r\nAll these ordering examples are in ascending (<span class=\”code\”>ASC</span>) order, which is the default sort order. The last <span class=\”code\”>SELECT</span> shows earlier sales first — and, within a given date, shows sales for <span class=\”code\”>‘Adams’</span> before <span class=\”code\”>‘Baker’</span>. If you prefer descending (<span class=\”code\”>DESC</span>) order, you can specify this order for one or more of the order columns, as follows:\r\n<pre class=\”code\”>SELECT * FROM SALES\r\nORDER BY SaleDate DESC, Salesperson ASC ;</pre>\r\nThis example specifies a descending order for sale dates, showing the more recent sales first, and an ascending order for salespeople, putting them in alphabetical order. That should give you a better picture of how Bennett’s performance stacks up against that of the other salespeople.”,”blurb”:””,”authors”:[{“authorId”:9559,”name”:”Allen G. Taylor”,”slug”:”allen-g-taylor”,”description”:” <p><b>Allen G. Taylor</b> is a 30&#45;year veteran of the computer industry and the author of over 40 books, including <b><i>SQL For Dummies</i></b> and <i>Crystal Reports For Dummies.</i> He lectures nationally on databases, innovation, and entrepreneurship. He also teaches database development internationally through a leading online education provider. “,”hasArticle”:false,”_links”:{“self”:”https://dummies-api.dummies.com/v2/authors/9559″}}],”primaryCategoryTaxonomy”:{“categoryId”:33608,”title”:”SQL”,”slug”:”sql”,”_links”:{“self”:”https://dummies-api.dummies.com/v2/categories/33608″}},”secondaryCategoryTaxonomy”:{“categoryId”:0,”title”:null,”slug”:null,”_links”:null},”tertiaryCategoryTaxonomy”:{“categoryId”:0,”title”:null,”slug”:null,”_links”:null},”trendingArticles”:null,”inThisArticle”:[{“label”:”GROUP BY clauses”,”target”:”#tab1″},{“label”:”HAVING clauses”,”target”:”#tab2″},{“label”:”ORDER BY clauses”,”target”:”#tab3″}],”relatedArticles”:{“fromBook”:[{“articleId”:260869,”title”:”Using SQL Constraints Within Transactions”,”slug”:”using-sql-constraints-within-transactions”,”categoryList”:[“technology”,”programming-web-design”,”sql”],”_links”:{“self”:”https://dummies-api.dummies.com/v2/articles/260869″}},{“articleId”:260866,”title”:”How to Use the SQL Union Join”,”slug”:”how-to-use-the-sql-union-join”,”categoryList”:[“technology”,”programming-web-design”,”sql”],”_links”:{“self”:”https://dummies-api.dummies.com/v2/articles/260866″}},{“articleId”:260727,”title”:”How to Declare a SQL Cursor”,”slug”:”how-to-declare-a-sql-cursor”,”categoryList”:[“technology”,”programming-web-design”,”sql”],”_links”:{“self”:”https://dummies-api.dummies.com/v2/articles/260727″}},{“articleId”:260720,”title”:”What is SQL?”,”slug”:”what-is-sql”,”categoryList”:[“technology”,”programming-web-design”,”sql”],”_links”:{“self”:”https://dummies-api.dummies.com/v2/articles/260720″}},{“articleId”:260678,”title”:”ODBC: Interfacing with SQL Databases”,”slug”:”odbc-interfacing-with-sql-databases”,”categoryList”:[“technology”,”programming-web-design”,”sql”],”_links”:{“self”:”https://dummies-api.dummies.com/v2/articles/260678″}}],”fromCategory”:[{“articleId”:260869,”title”:”Using SQL Constraints Within Transactions”,”slug”:”using-sql-constraints-within-transactions”,”categoryList”:[“technology”,”programming-web-design”,”sql”],”_links”:{“self”:”https://dummies-api.dummies.com/v2/articles/260869″}},{“articleId”:260866,”title”:”How to Use the SQL Union Join”,”slug”:”how-to-use-the-sql-union-join”,”categoryList”:[“technology”,”programming-web-design”,”sql”],”_links”:{“self”:”https://dummies-api.dummies.com/v2/articles/260866″}},{“articleId”:260727,”title”:”How to Declare a SQL Cursor”,”slug”:”how-to-declare-a-sql-cursor”,”categoryList”:[“technology”,”programming-web-design”,”sql”],”_links”:{“self”:”https://dummies-api.dummies.com/v2/articles/260727″}},{“articleId”:260720,”title”:”What is SQL?”,”slug”:”what-is-sql”,”categoryList”:[“technology”,”programming-web-design”,”sql”],”_links”:{“self”:”https://dummies-api.dummies.com/v2/articles/260720″}},{“articleId”:260678,”title”:”ODBC: Interfacing with SQL Databases”,”slug”:”odbc-interfacing-with-sql-databases”,”categoryList”:[“technology”,”programming-web-design”,”sql”],”_links”:{“self”:”https://dummies-api.dummies.com/v2/articles/260678″}}]},”hasRelatedBookFromSearch”:false,”relatedBook”:{“bookId”:281871,”slug”:”sql-for-dummies-9th-edition”,”isbn”:”9781119527077″,”categoryList”:[“technology”,”programming-web-design”,”sql”],”amazon”:{“default”:”https://www.amazon.com/gp/product/1119527074/ref=as_li_tl?ie=UTF8&tag=wiley01-20″,”ca”:”https://www.amazon.ca/gp/product/1119527074/ref=as_li_tl?ie=UTF8&tag=wiley01-20″,”indigo_ca”:”http://www.tkqlhce.com/click-9208661-13710633?url=https://www.chapters.indigo.ca/en-ca/books/product/1119527074-item.html&cjsku=978111945484″,”gb”:”https://www.amazon.co.uk/gp/product/1119527074/ref=as_li_tl?ie=UTF8&tag=wiley01-20″,”de”:”https://www.amazon.de/gp/product/1119527074/ref=as_li_tl?ie=UTF8&tag=wiley01-20″},”image”:{“src”:”https://www.dummies.com/wp-content/uploads/sql-for-dummies-9th-edition-cover-9781119527077-203×255.jpg”,”width”:203,”height”:255},”title”:”SQL For Dummies”,”testBankPinActivationLink”:””,”bookOutOfPrint”:false,”authorsInfo”:”<p><b data-author-id=\”9559\”>Allen G. Taylor</b> is a 30-year veteran of the computer industry and the author of over 40 books, including <b><i>SQL For Dummies</i></b> and <i>Crystal Reports For Dummies.</i> He lectures nationally on databases, innovation, and entrepreneurship. He also teaches database development internationally through a leading online education provider. </p>”,”authors”:[{“authorId”:9559,”name”:”Allen G. Taylor”,”slug”:”allen-g-taylor”,”description”:” <p><b>Allen G. Taylor</b> is a 30&#45;year veteran of the computer industry and the author of over 40 books, including <b><i>SQL For Dummies</i></b> and <i>Crystal Reports For Dummies.</i> He lectures nationally on databases, innovation, and entrepreneurship. He also teaches database development internationally through a leading online education provider. “,”hasArticle”:false,”_links”:{“self”:”https://dummies-api.dummies.com/v2/authors/9559″}}],”_links”:{“self”:”https://dummies-api.dummies.com/v2/books/”}},”collections”:[],”articleAds”:{“footerAd”:”<div class=\”du-ad-region row\” id=\”article_page_adhesion_ad\”><div class=\”du-ad-unit col-md-12\” data-slot-id=\”article_page_adhesion_ad\” data-refreshed=\”false\” \r\n data-target = \”[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;sql&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119527077&quot;]}]\” id=\”du-slot-63221b16004ac\”></div></div>”,”rightAd”:”<div class=\”du-ad-region row\” id=\”article_page_right_ad\”><div class=\”du-ad-unit col-md-12\” data-slot-id=\”article_page_right_ad\” data-refreshed=\”false\” \r\n data-target = \”[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;sql&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119527077&quot;]}]\” id=\”du-slot-63221b1601031\”></div></div>”},”articleType”:{“articleType”:”Articles”,”articleList”:null,”content”:null,”videoInfo”:{“videoId”:null,”name”:null,”accountId”:null,”playerId”:null,”thumbnailUrl”:null,”description”:null,”uploadDate”:null}},”sponsorship”:{“sponsorshipPage”:false,”backgroundImage”:{“src”:null,”width”:0,”height”:0},”brandingLine”:””,”brandingLink”:””,”brandingLogo”:{“src”:null,”width”:0,”height”:0},”sponsorAd”:””,”sponsorEbookTitle”:””,”sponsorEbookLink”:””,”sponsorEbookImage”:{“src”:null,”width”:0,”height”:0}},”primaryLearningPath”:”Advance”,”lifeExpectancy”:”Two years”,”lifeExpectancySetFrom”:”2022-01-14T00:00:00+00:00″,”dummiesForKids”:”no”,”sponsoredContent”:”no”,”adInfo”:””,”adPairKey”:[]},”status”:”publish”,”visibility”:”public”,”articleId”:160800},”articleLoadedStatus”:”success”},”listState”:{“list”:{},”objectTitle”:””,”status”:”initial”,”pageType”:null,”objectId”:null,”page”:1,”sortField”:”time”,”sortOrder”:1,”categoriesIds”:[],”articleTypes”:[],”filterData”:{},”filterDataLoadedStatus”:”initial”,”pageSize”:10},”adsState”:{“pageScripts”:{“headers”:{“timestamp”:”2023-04-21T05:50:01+00:00″},”adsId”:0,”data”:{“scripts”:[{“pages”:[“all”],”location”:”header”,”script”:”<!–Optimizely Script–>\r\n<script src=\”https://cdn.optimizely.com/js/10563184655.js\”></script>”,”enabled”:false},{“pages”:[“all”],”location”:”header”,”script”:”<!– comScore Tag –>\r\n<script>var _comscore = _comscore || [];_comscore.push({ c1: \”2\”, c2: \”15097263\” });(function() {var s = document.createElement(\”script\”), el = document.getElementsByTagName(\”script\”)[0]; s.async = true;s.src = (document.location.protocol == \”https:\” ? \”https://sb\” : \”http://b\”) + \”.scorecardresearch.com/beacon.js\”;el.parentNode.insertBefore(s, el);})();</script><noscript><img src=\”https://sb.scorecardresearch.com/p?c1=2&c2=15097263&cv=2.0&cj=1\” /></noscript>\r\n<!– / comScore Tag –>”,”enabled”:true},{“pages”:[“all”],”location”:”footer”,”script”:”<!–BEGIN QUALTRICS WEBSITE FEEDBACK SNIPPET–>\r\n<script type=’text/javascript’>\r\n(function(){var g=function(e,h,f,g){\r\nthis.get=function(a){for(var a=a+\”=\”,c=document.cookie.split(\”;\”),b=0,e=c.length;b<e;b++){for(var d=c[b];\” \”==d.charAt(0);)d=d.substring(1,d.length);if(0==d.indexOf(a))return d.substring(a.length,d.length)}return null};\r\nthis.set=function(a,c){var b=\”\”,b=new Date;b.setTime(b.getTime()+6048E5);b=\”; expires=\”+b.toGMTString();document.cookie=a+\”=\”+c+b+\”; path=/; \”};\r\nthis.check=function(){var a=this.get(f);if(a)a=a.split(\”:\”);else if(100!=e)\”v\”==h&&(e=Math.random()>=e/100?0:100),a=[h,e,0],this.set(f,a.join(\”:\”));else return!0;var c=a[1];if(100==c)return!0;switch(a[0]){case \”v\”:return!1;case \”r\”:return c=a[2]%Math.floor(100/c),a[2]++,this.set(f,a.join(\”:\”)),!c}return!0};\r\nthis.go=function(){if(this.check()){var a=document.createElement(\”script\”);a.type=\”text/javascript\”;a.src=g;document.body&&document.body.appendChild(a)}};\r\nthis.start=function(){var t=this;\”complete\”!==document.readyState?window.addEventListener?window.addEventListener(\”load\”,function(){t.go()},!1):window.attachEvent&&window.attachEvent(\”onload\”,function(){t.go()}):t.go()};};\r\ntry{(new g(100,\”r\”,\”QSI_S_ZN_5o5yqpvMVjgDOuN\”,\”https://zn5o5yqpvmvjgdoun-wiley.siteintercept.qualtrics.com/SIE/?Q_ZID=ZN_5o5yqpvMVjgDOuN\”)).start()}catch(i){}})();\r\n</script><div id=’ZN_5o5yqpvMVjgDOuN’><!–DO NOT REMOVE-CONTENTS PLACED HERE–></div>\r\n<!–END WEBSITE FEEDBACK SNIPPET–>”,”enabled”:false},{“pages”:[“all”],”location”:”header”,”script”:”<!– Hotjar Tracking Code for http://www.dummies.com –>\r\n<script>\r\n (function(h,o,t,j,a,r){\r\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\r\n h._hjSettings={hjid:257151,hjsv:6};\r\n a=o.getElementsByTagName(‘head’)[0];\r\n r=o.createElement(‘script’);r.async=1;\r\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\r\n a.appendChild(r);\r\n })(window,document,’https://static.hotjar.com/c/hotjar-‘,’.js?sv=’);\r\n</script>”,”enabled”:false},{“pages”:[“article”],”location”:”header”,”script”:”<!– //Connect Container: dummies –> <script src=\”//get.s-onetag.com/bffe21a1-6bb8-4928-9449-7beadb468dae/tag.min.js\” async defer></script>”,”enabled”:true},{“pages”:[“homepage”],”location”:”header”,”script”:”<meta name=\”facebook-domain-verification\” content=\”irk8y0irxf718trg3uwwuexg6xpva0\” />”,”enabled”:true},{“pages”:[“homepage”,”article”,”category”,”search”],”location”:”footer”,”script”:”<!– Facebook Pixel Code –>\r\n<noscript>\r\n<img height=\”1\” width=\”1\” src=\”https://www.facebook.com/tr?id=256338321977984&ev=PageView&noscript=1\”/>\r\n</noscript>\r\n<!– End Facebook Pixel Code –>”,”enabled”:true}]}},”pageScriptsLoadedStatus”:”success”},”navigationState”:{“navigationCollections”:[{“collectionId”:287568,”title”:”BYOB (Be Your Own Boss)”,”hasSubCategories”:false,”url”:”/collection/for-the-entry-level-entrepreneur-287568″},{“collectionId”:293237,”title”:”Be a Rad Dad”,”hasSubCategories”:false,”url”:”/collection/be-the-best-dad-293237″},{“collectionId”:295890,”title”:”Career Shifting”,”hasSubCategories”:false,”url”:”/collection/career-shifting-295890″},{“collectionId”:294090,”title”:”Contemplating the Cosmos”,”hasSubCategories”:false,”url”:”/collection/theres-something-about-space-294090″},{“collectionId”:287563,”title”:”For Those Seeking Peace of Mind”,”hasSubCategories”:false,”url”:”/collection/for-those-seeking-peace-of-mind-287563″},{“collectionId”:287570,”title”:”For the Aspiring Aficionado”,”hasSubCategories”:false,”url”:”/collection/for-the-bougielicious-287570″},{“collectionId”:291903,”title”:”For the Budding Cannabis Enthusiast”,”hasSubCategories”:false,”url”:”/collection/for-the-budding-cannabis-enthusiast-291903″},{“collectionId”:291934,”title”:”For the Exam-Season Crammer”,”hasSubCategories”:false,”url”:”/collection/for-the-exam-season-crammer-291934″},{“collectionId”:287569,”title”:”For the Hopeless Romantic”,”hasSubCategories”:false,”url”:”/collection/for-the-hopeless-romantic-287569″},{“collectionId”:296450,”title”:”For the Spring Term Learner”,”hasSubCategories”:false,”url”:”/collection/for-the-spring-term-student-296450″}],”navigationCollectionsLoadedStatus”:”success”,”navigationCategories”:{“books”:{“0”:{“data”:[{“categoryId”:33512,”title”:”Technology”,”hasSubCategories”:true,”url”:”/category/books/technology-33512″},{“categoryId”:33662,”title”:”Academics & The Arts”,”hasSubCategories”:true,”url”:”/category/books/academics-the-arts-33662″},{“categoryId”:33809,”title”:”Home, Auto, & Hobbies”,”hasSubCategories”:true,”url”:”/category/books/home-auto-hobbies-33809″},{“categoryId”:34038,”title”:”Body, Mind, & Spirit”,”hasSubCategories”:true,”url”:”/category/books/body-mind-spirit-34038″},{“categoryId”:34224,”title”:”Business, Careers, & Money”,”hasSubCategories”:true,”url”:”/category/books/business-careers-money-34224″}],”breadcrumbs”:[],”categoryTitle”:”Level 0 Category”,”mainCategoryUrl”:”/category/books/level-0-category-0″}},”articles”:{“0”:{“data”:[{“categoryId”:33512,”title”:”Technology”,”hasSubCategories”:true,”url”:”/category/articles/technology-33512″},{“categoryId”:33662,”title”:”Academics & The Arts”,”hasSubCategories”:true,”url”:”/category/articles/academics-the-arts-33662″},{“categoryId”:33809,”title”:”Home, Auto, & Hobbies”,”hasSubCategories”:true,”url”:”/category/articles/home-auto-hobbies-33809″},{“categoryId”:34038,”title”:”Body, Mind, & Spirit”,”hasSubCategories”:true,”url”:”/category/articles/body-mind-spirit-34038″},{“categoryId”:34224,”title”:”Business, Careers, & Money”,”hasSubCategories”:true,”url”:”/category/articles/business-careers-money-34224″}],”breadcrumbs”:[],”categoryTitle”:”Level 0 Category”,”mainCategoryUrl”:”/category/articles/level-0-category-0″}}},”navigationCategoriesLoadedStatus”:”success”},”searchState”:{“searchList”:[],”searchStatus”:”initial”,”relatedArticlesList”:[],”relatedArticlesStatus”:”initial”},”routeState”:{“name”:”Article3″,”path”:”/article/technology/programming-web-design/sql/how-to-use-group-by-having-and-order-by-sql-clauses-160800/”,”hash”:””,”query”:{},”params”:{“category1″:”technology”,”category2″:”programming-web-design”,”category3″:”sql”,”article”:”how-to-use-group-by-having-and-order-by-sql-clauses-160800″},”fullPath”:”/article/technology/programming-web-design/sql/how-to-use-group-by-having-and-order-by-sql-clauses-160800/”,”meta”:{“routeType”:”article”,”breadcrumbInfo”:{“suffix”:”Articles”,”baseRoute”:”/category/articles”},”prerenderWithAsyncData”:true},”from”:{“name”:null,”path”:”/”,”hash”:””,”query”:{},”params”:{},”fullPath”:”/”,”meta”:{}}},”dropsState”:{“submitEmailResponse”:false,”status”:”initial”},”sfmcState”:{“status”:”initial”},”profileState”:{“auth”:{},”userOptions”:{},”status”:”success”}}

Alternate Text Gọi ngay