{"id":107292,"date":"2022-02-17T11:00:00","date_gmt":"2022-02-17T09:00:00","guid":{"rendered":"https:\/\/examples.javacodegeeks.com\/?p=107292"},"modified":"2022-02-15T13:13:59","modified_gmt":"2022-02-15T11:13:59","slug":"sql-having-clause","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/","title":{"rendered":"SQL HAVING Clause"},"content":{"rendered":"<h2 class=\"wp-block-heading\" id=\"h-1-introduction\">1. Introduction<\/h2>\n<p>A <a href=\"https:\/\/www.w3schools.com\/sql\/sql_having.asp\" target=\"_blank\" rel=\"noreferrer noopener\">SQL HAVING<\/a> clause is a part of a <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/queries\/select-transact-sql?view=sql-server-ver15\" target=\"_blank\" rel=\"noreferrer noopener\">SQL SELECT<\/a> statement that filters out the rows that don&#8217;t match the aggregating conditions. Here is the syntax for the <strong>HAVING <\/strong>clause in a <strong>SELECT <\/strong>statement:<\/p>\n<p><span style=\"text-decoration: underline\"><em>HAVING Syntax<\/em><\/span> <\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT select_list [ INTO new_table ]\n[ FROM table_source ] \n[ GROUP BY group_by_expression ]\n[ HAVING search_condition ]\n[ ORDER BY columns ]<\/pre>\n<p><strong>Note<\/strong>: the <strong>Having <\/strong>clause is right after a <strong>Group By<\/strong> clause if it exists and before an <strong>Order By<\/strong> clause. The <strong>search_condition<\/strong> after <strong>HAVING <\/strong>must return a <strong>boolean <\/strong>value.<\/p>\n<p>In this example, I will demonstrate the SQL HAVING clause:<\/p>\n<ul class=\"wp-block-list\">\n<li>with aggregate functions: <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/count-transact-sql?view=sql-server-ver15\" target=\"_blank\" rel=\"noreferrer noopener\">count<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/avg-transact-sql?view=sql-server-ver15\" target=\"_blank\" rel=\"noreferrer noopener\">avg<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/sum-transact-sql?view=sql-server-ver15\" target=\"_blank\" rel=\"noreferrer noopener\">sum<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/min-transact-sql?view=sql-server-ver15\" target=\"_blank\" rel=\"noreferrer noopener\">min<\/a>, and <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/max-transact-sql?view=sql-server-ver15\" target=\"_blank\" rel=\"noreferrer noopener\">max<\/a>.<\/li>\n<li>with a <a href=\"https:\/\/www.w3schools.com\/sql\/sql_groupby.asp\" target=\"_blank\" rel=\"noreferrer noopener\">GROUP BY<\/a> clause.<\/li>\n<li>without a <strong>GROUP BY<\/strong> clause.<\/li>\n<li>with more than one aggregate functions.<\/li>\n<li>with an <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/queries\/select-order-by-clause-transact-sql?view=sql-server-ver15\" target=\"_blank\" rel=\"noreferrer noopener\">ORDER BY<\/a> clause.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-2-technologies-used\">2. Technologies Used<\/h2>\n<p>The example code in this article was built and run using:<\/p>\n<ul class=\"wp-block-list\">\n<li>SQL<\/li>\n<li>MS SQL Server<\/li>\n<li>SQuirrel Client 3.9.0<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-3-setup-data\">3. Setup Data<\/h2>\n<p>In this step, I will create two database tables:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>categories&nbsp;<\/strong>\u2013 has two columns:&nbsp;<strong>category_id&nbsp;<\/strong>and&nbsp;<strong>category_name<\/strong>. It has three records.<\/li>\n<li><strong>products&nbsp;<\/strong>\u2013 has five columns:&nbsp;<strong>product_id<\/strong>,&nbsp;<strong>category_id,<\/strong>&nbsp;<strong>product_name<\/strong>, <strong>price<\/strong>, and&nbsp;<strong>release_date<\/strong>. It has eight records.<\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline\"><em>setupdata.sql<\/em><\/span>\n<\/p>\n<pre class=\"wp-block-preformatted brush:sql\">create table categories (\ncategory_id  INT,\ncategory_name VARCHAR(40)\n);\n\ncreate table products (\nproduct_id INT,\ncategory_id  INT,\nproduct_name VARCHAR(40),\nprice\tDECIMAL(5,2)  ,\nrelease_date DATE\n);\n\ninsert into categories ( category_id  , category_name ) values(1, 'Mobile');\ninsert into categories ( category_id  , category_name ) values(2, 'Headphone');\ninsert into categories ( category_id  , category_name ) values(3, 'Tablet');\ninsert into products ( product_id , category_id  , product_name, price, release_date ) values(1027,2, 'Headphone 700',87.99, '5\/13\/2019');\ninsert into products ( product_id , category_id  , product_name, price, release_date ) values(1028,2, 'Headphone 450BT', 97.99, '2\/4\/2020');\ninsert into products ( product_id , category_id  , product_name, price, release_date ) values(1029,2, 'HD 1000XM3', 107.99, '8\/5\/2018');\ninsert into products ( product_id , category_id  , product_name, price, release_date ) values(1030,2, 'HD SoundES18',117.99,  '1\/1\/2017');\ninsert into products ( product_id , category_id  , product_name, price, release_date ) values(1021,1, 'APPLE 700',400.99,  '9\/20\/2019');\ninsert into products ( product_id , category_id  , product_name, price, release_date ) values(1022,1, 'Samsung 5',357.99,  '8\/23\/2019');\ninsert into products ( product_id , category_id  , product_name, price, release_date ) values(1035,3, 'GalatS6',187.99,  '10\/13\/2019');\ninsert into products ( product_id , category_id  , product_name, price, release_date ) values(1036,3, 'MS', 250.99, '6\/13\/2017');\n<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Verify the data with a Select statement<\/em><\/span><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT category_id,\n       count(*) totalProductCount\nFROM   products\nGROUP  BY category_id <\/pre>\n<p><span style=\"text-decoration: underline\"><em>Query Results<\/em><\/span><\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>category_id<\/td>\n<td>totalProductCount<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>2<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table 1 Category and Its Product Count<\/figcaption><\/figure>\n<p>As the results show, only the <strong>category_id = 2<\/strong> has more than 2 products.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-4-sql-having-clause\">4. SQL Having Clause<\/h2>\n<h3 class=\"wp-block-heading\" id=\"h-4-1-having-clause-without-group-by\">4.1 HAVING Clause Without Group By<\/h3>\n<p>In this step, I will use a <strong>HAVING<\/strong> clause to find the minimum and maximum <strong>price<\/strong>s from the <strong>products<\/strong> table when the minimum and maximum prices are different.<\/p>\n<p><span style=\"text-decoration: underline\"><em>HAVING min(price) != Max(price)<\/em><\/span>\n<\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT Min(price) min,\n       Max(price) max\nFROM   products\nHAVING Min(price) != Max(price); <\/pre>\n<p><span style=\"text-decoration: underline\"><em>Query Results<\/em><\/span>\n<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>min<\/td>\n<td>max<\/td>\n<\/tr>\n<tr>\n<td>87.99<\/td>\n<td>400.99<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table 2 Minimum and Maximum Prices<\/figcaption><\/figure>\n<p><strong>Note<\/strong>: when a <strong>HAVING<\/strong> clause is used without a <strong>GROUP BY<\/strong> clause, then the aggregate function is applied to the entire table. In this case, it returns 1 row.<\/p>\n<p>The next query returns no data.<\/p>\n<p><span style=\"text-decoration: underline\"><em>HAVING Min(price) = Max(price)<\/em><\/span>\n<\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT Min(price) min,\n       Max(price) max\nFROM   products\nHAVING Min(price) = Max(price); <\/pre>\n<p><span style=\"text-decoration: underline\"><em>No data was returned<\/em><\/span><\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>min<\/td>\n<td>max<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table 3 No Data Found<\/figcaption><\/figure>\n<h3 class=\"wp-block-heading\" id=\"h-4-2-group-by-category-having-count-greater-than-2\">4.2 GROUP BY Category HAVING Count Greater Than 2<\/h3>\n<p>In this step, I will use a <strong>HAVING<\/strong> clause with a <strong>GROUP BY <\/strong>clause to list the minimum and maximum prices for each category.<\/p>\n<p><span style=\"text-decoration: underline\"><em>HAVING after GROUP BY<\/em><\/span>\n<\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT category_id,\n       Min(price) min,\n       Max(price) max\nFROM   products\nGROUP  BY category_id\nHAVING Min(price) != Max(price); <\/pre>\n<p><span style=\"text-decoration: underline\"><em>Query Results<\/em><\/span>\n<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>category_id<\/td>\n<td>min<\/td>\n<td>max<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>357.99<\/td>\n<td>400.99<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>87.99<\/td>\n<td>117.99<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>187.99<\/td>\n<td>250.99<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table 4 List both Minimum and Maximum Prices for Each Category<\/figcaption><\/figure>\n<p>The next query uses a <strong>HAVING<\/strong> clause with a <strong>GROUP BY <\/strong>clause which filters the categories with less than 2 products.<\/p>\n<p><span style=\"text-decoration: underline\"><em>HAVING count(*&gt; 2<\/em><\/span>\n<\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT   category_id,\n         Sum(price) totalProductPrice\nFROM     products\nGROUP BY category_id\nHAVING   Count(*) &gt;2;<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Query Results<\/em><\/span>\n<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>category_id<\/td>\n<td>totalProductPrice<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>411.96<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table 5 List Category Total Product Price When It Has More Than 2 Products<\/figcaption><\/figure>\n<h3 class=\"wp-block-heading\" id=\"h-4-3-group-by-category-having-sum-greater-than-300\">4.3 Group By Category Having Sum Greater Than 300<\/h3>\n<p>In this step, I will demonstrate two ways to use a HAVING clause with a joined table.<\/p>\n<p><span style=\"text-decoration: underline\"><em>HAVING Sum(price) &gt; 300<\/em><\/span>\n<\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT   c.category_id,\n         c.category_name ,\n         Sum(price) totalProductPrice\nFROM     products p,\n         categories c\nWHERE    p.category_id = c.category_id\nGROUP BY c.category_id,\n         c.category_name\nHAVING   Sum(price) &gt;300;<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Query Results<\/em><\/span> <\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>category_id<\/td>\n<td>category_name<\/td>\n<td>totalProductPrice<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>Mobile<\/td>\n<td>758.98<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Headphone<\/td>\n<td>411.96<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Tablet<\/td>\n<td>438.98<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table 6 Category Total Product Prices<\/figcaption><\/figure>\n<p>In th next query, the joined clause is applied to the filtered query results.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Having in a subQuery<\/em><\/span>\n<\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT *\nFROM   categories c,\n       (SELECT category_id,\n               Sum(price) totalProductPrice\n        FROM   products\n        GROUP  BY category_id\n        HAVING Count(*) &gt; 2) filterdV\nWHERE  c.category_id = filterdV.category_id; <\/pre>\n<p><span style=\"text-decoration: underline\"><em>Query Results<\/em><\/span>\n<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>category_id<\/td>\n<td>category_name<\/td>\n<td>category_id<\/td>\n<td>totalProductPrice<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Headphone<\/td>\n<td>2<\/td>\n<td>411.96<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table 7 Category&#8217;s Total Product Prices Filtering with More Than 2 Products<\/figcaption><\/figure>\n<h3 class=\"wp-block-heading\" id=\"h-4-4-group-by-category-having-sum-between-300-and-500\">4.4 Group by Category HAVING Sum between 300 and 500<\/h3>\n<p>In this step, I will show two queries with more than one condition used in the HAVING clause.<\/p>\n<p><span style=\"text-decoration: underline\"><em>HAVING with 2 Conditions<\/em><\/span>\n<\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT   c.category_id,\n         c.category_name ,\n         Sum(price) totalProductPrice\nFROM     products p,\n         categories c\nWHERE    p.category_id = c.category_id\nGROUP BY c.category_id,\n         c.category_name\nHAVING   Sum(price) &gt;300 and sum(price) &lt; 500;<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Query Results<\/em><\/span>\n<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>category_id<\/td>\n<td>category_name<\/td>\n<td>totalProductPrice<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Headphone<\/td>\n<td>411.96<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Tablet<\/td>\n<td>438.98<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table 8 Category with Total Product Prices Between 300 And 500<\/figcaption><\/figure>\n<p>The next query shows categories with more than 2 products and a total price of more than 300.<\/p>\n<p><span style=\"text-decoration: underline\"><em>HAVING with 2 Conditions -2<\/em><\/span>\n<\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT   c.category_id,\n         c.category_name ,\n         Sum(price) totalProductPrice\nFROM     products p,\n         categories c\nWHERE    p.category_id = c.category_id\nGROUP BY c.category_id,\n         c.category_name\nHAVING   Sum(price) &gt;300 and count(*) &gt; 2<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Query Results<\/em><\/span>\n<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>category_id<\/td>\n<td>category_name<\/td>\n<td>totalProductPrice<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Headphone<\/td>\n<td>411.96<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table 9 Category with More Than 2 Products and Total Price Greater Than 300<\/figcaption><\/figure>\n<h3 class=\"wp-block-heading\" id=\"h-4-5-having-avg-and-order-by-avg\">4.5 Having Avg and Order By Avg<\/h3>\n<p>In this step, I will show how to find the categories whose average product price is more than 100, and the query results are ordered by the average product price.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Having Average With Order By<\/em><\/span>\n<\/p>\n<pre class=\"wp-block-preformatted brush:sql\">SELECT   c.category_id,\n         c.category_name ,\n         avg(price) avgPrice\nFROM     products p,\n         categories c\nWHERE    p.category_id = c.category_id\nGROUP BY c.category_id,\n         c.category_name\nHAVING   avg(price) &gt; 100 \norder by avg(price);<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Query Results<\/em><\/span>\n<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>category_id<\/td>\n<td>category_name<\/td>\n<td>avgPrice<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Headphone<\/td>\n<td>102.99<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Tablet<\/td>\n<td>219.49<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>Mobile<\/td>\n<td>379.49<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table 10 Order by Average Price<\/figcaption><\/figure>\n<h2 class=\"wp-block-heading\" id=\"h-5-summary\">5. Summary<\/h2>\n<p>The <strong>HAVING <\/strong>clause is used in a SELECT statement which specifies conditions to filter which group results appear in the results. The conditions are the <strong>Boolean <\/strong>type which can be used with logical operators: <strong>AND<\/strong> and <strong>OR<\/strong>. In this example, I demonstrated the following usages of a <strong>Having <\/strong>clause:<\/p>\n<ul class=\"wp-block-list\">\n<li>H<strong>aving min(price) ! = max(price)<\/strong> clause without a <strong>Group by<\/strong> clause.<\/li>\n<li><strong>Group by<\/strong> category and filtering with <strong>Having count(product) &gt; 2<\/strong>.<\/li>\n<li><strong>Group by<\/strong> category and filter with <strong>Having sum(price) &gt; 300<\/strong>.<\/li>\n<li><strong>Group by<\/strong> category and filter with <strong>Having avg(price) &gt; 100<\/strong>, then <strong>Order By<\/strong> avg(price).<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-6-download-the-source-code\">6. Download the Source Code<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/02\/sql_having-2.zip\"><strong>SQL HAVING Clause<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction A SQL HAVING clause is a part of a SQL SELECT statement that filters out the rows that don&#8217;t match the aggregating conditions. Here is the syntax for the HAVING clause in a SELECT statement: HAVING Syntax SELECT select_list [ INTO new_table ] [ FROM table_source ] [ GROUP BY group_by_expression ] [ &hellip;<\/p>\n","protected":false},"author":140,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[1055],"class_list":["post-107292","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql","tag-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SQL HAVING Clause - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"A SQL HAVING clause is a part of a SQL SELECT statement that filters out the rows that don&#039;t match the aggregating conditions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL HAVING Clause - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"A SQL HAVING clause is a part of a SQL SELECT statement that filters out the rows that don&#039;t match the aggregating conditions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-17T09:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mary Zheng\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mary Zheng\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/\"},\"author\":{\"name\":\"Mary Zheng\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae\"},\"headline\":\"SQL HAVING Clause\",\"datePublished\":\"2022-02-17T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/\"},\"wordCount\":740,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"sql\"],\"articleSection\":[\"sql\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/\",\"name\":\"SQL HAVING Clause - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2022-02-17T09:00:00+00:00\",\"description\":\"A SQL HAVING clause is a part of a SQL SELECT statement that filters out the rows that don't match the aggregating conditions.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"sql\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"SQL HAVING Clause\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae\",\"name\":\"Mary Zheng\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg\",\"caption\":\"Mary Zheng\"},\"description\":\"Mary has graduated from Mechanical Engineering department at ShangHai JiaoTong University. She also holds a Master degree in Computer Science from Webster University. During her studies she has been involved with a large number of projects ranging from programming and software engineering. She works as a senior Software Engineer in the telecommunications sector where she acts as a leader and works with others to design, implement, and monitor the software solution.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/mary-zheng\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL HAVING Clause - Java Code Geeks","description":"A SQL HAVING clause is a part of a SQL SELECT statement that filters out the rows that don't match the aggregating conditions.","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:\/\/examples.javacodegeeks.com\/sql-having-clause\/","og_locale":"en_US","og_type":"article","og_title":"SQL HAVING Clause - Java Code Geeks","og_description":"A SQL HAVING clause is a part of a SQL SELECT statement that filters out the rows that don't match the aggregating conditions.","og_url":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2022-02-17T09:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Mary Zheng","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Mary Zheng","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/"},"author":{"name":"Mary Zheng","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae"},"headline":"SQL HAVING Clause","datePublished":"2022-02-17T09:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/"},"wordCount":740,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["sql"],"articleSection":["sql"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/","url":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/","name":"SQL HAVING Clause - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2022-02-17T09:00:00+00:00","description":"A SQL HAVING clause is a part of a SQL SELECT statement that filters out the rows that don't match the aggregating conditions.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/sql-having-clause\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/sql-having-clause\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"sql","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/"},{"@type":"ListItem","position":5,"name":"SQL HAVING Clause"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae","name":"Mary Zheng","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg","caption":"Mary Zheng"},"description":"Mary has graduated from Mechanical Engineering department at ShangHai JiaoTong University. She also holds a Master degree in Computer Science from Webster University. During her studies she has been involved with a large number of projects ranging from programming and software engineering. She works as a senior Software Engineer in the telecommunications sector where she acts as a leader and works with others to design, implement, and monitor the software solution.","url":"https:\/\/examples.javacodegeeks.com\/author\/mary-zheng\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/107292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/140"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=107292"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/107292\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=107292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=107292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=107292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}