<html>
<head>
<!-- Template generated by Exclaimer Signature Manager Exchange Edition on 10:16:01 Tuesday, 28 May 2019 -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">P.ImprintUniqueID {
        MARGIN: 0cm 0cm 0pt
}
LI.ImprintUniqueID {
        MARGIN: 0cm 0cm 0pt
}
DIV.ImprintUniqueID {
        MARGIN: 0cm 0cm 0pt
}
TABLE.ImprintUniqueIDTable {
        MARGIN: 0cm 0cm 0pt
}
DIV.Section1 {
        page: Section1
}
.ExternalClass * {
        LINE-HEIGHT: 100%
}
</style><style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} p.ImprintUniqueID
        {margin:0cm 0cm 0pt}
li.ImprintUniqueID
        {margin:0cm 0cm 0pt}
div.ImprintUniqueID
        {margin:0cm 0cm 0pt}
table.ImprintUniqueIDTable
        {margin:0cm 0cm 0pt}
div.Section1
        {}--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p class="ImprintUniqueID"></p>
<p>At a guess, you are asking for the count(*) from both tables... you only want the count from table 1.<br>
</p>
<p><br>
</p>
<p>SELECT COUNT(Table_1.wkb_geometry) FROM Table_1,Table_2 WHERE ST_Intersects(Table_1.wkb_geometry,Table_2.wkb_geometry);<br>
</p>
<p><br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div class="BodyFragment">
<div class="PlainText">Brent Wood<br>
<br>
Programme leader: Environmental Information Delivery<br>
NIWA<br>
DDI:  +64 (4) 3860529</div>
</div>
</div>
</div>
<div style="color: rgb(33, 33, 33);"></div>
<br>
<br>
<table class="ImprintUniqueIDTable" style="HEIGHT: 89px; TABLE-LAYOUT: fixed; WIDTH: 100%" cellspacing="0" cellpadding="0" align="center" border="0">
<tbody>
<tr>
<td style="TABLE-LAYOUT: fixed; WIDTH: 180px"><a href="http://www.niwa.co.nz" target=""><img width="180" height="88" style="border: 0px Solid ; " src="cid:imagee12d55.PNG@cdb06479.44912a6c"></a><br>
<br>
</td>
<td style="TABLE-LAYOUT: fixed; WIDTH: 1159px">
<table cellpadding="0" cellspacing="0" class="07b63f74-9868-4ae3-b533-9388a944d548Table">
<tbody>
<tr>
<td nowrap="1"><font style="font-family:Calibri;font-size:10pt;color:#000000;font-weight:bold;">Brent Wood</font></td>
</tr>
<tr>
<td nowrap="1"><font style="font-family:Calibri Light;font-size:9pt;color:#000000;font-weight:bold;">Principal Technician - GIS and Spatial Data Management</font></td>
</tr>
<tr>
<td nowrap="1"><font style="font-family:Calibri Light;font-size:9pt;color:#000000;font-weight:bold;">Programme Leader - Environmental Information Delivery</font></td>
</tr>
<tr>
<td nowrap="1">
<table cellspacing="0" cellpadding="0" class="07b63f74-9868-4ae3-b533-9388a944d548Table" style="font-family:Calibri; font-size:9pt;">
<tbody>
<tr>
<td nowrap="1"><font style="font-family:Calibri;font-size:9pt;"><font style="font-family:Calibri;font-size:9pt;"><font style="font-family:Calibri;font-size:9pt;color:#244061;font-weight:bold;">T
</font><font style="font-family:Calibri;font-size:9pt;">+64-4-386-0529</font></font></font></td>
<td nowrap="1" align="Center"><font style="font-family:Calibri;font-size:9pt;"><font style="font-family:Calibri;font-size:9pt;"><font style="font-family:Calibri;font-size:9pt;"> </font></font></font></td>
<td nowrap="1"><font style="font-family:Calibri;font-size:9pt;"><font style="font-family:Calibri;font-size:9pt;"></font></font></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td nowrap="1"><font style="font-family:Calibri;font-size:9pt;color:#000000;">National Institute of Water & Atmospheric Research Ltd (NIWA)</font></td>
</tr>
<tr>
<td nowrap="1"><font style="font-family:Calibri;font-size:9pt;color:#000000;">301 Evans Bay Parade, Greta Point, Wellington</font></td>
</tr>
<tr>
<td nowrap="1"><font style="font-family:Calibri;font-size:9pt;color:#000000;font-weight:bold;">Connect with NIWA:
</font><span style="font-family:Calibri;font-size:9pt;"><a href="https://www.niwa.co.nz" title="" target="" style="font-family:Calibri;font-size:9pt;"><span style="font-family:Calibri; font-size:9pt;">niwa.co.nz</span></a></span><font style="font-family:calibri;font-size:9pt;"> </font><span style="font-family:calibri;font-size:9pt;"><a href="https://www.facebook.com/nzniwa" title="" target="" style="font-family:calibri;font-size:9pt;"><span style="font-family:calibri; font-size:9pt;">Facebook</span></a></span><font style="font-family:Calibri;font-size:9pt;"> </font><span style="font-family:Calibri;font-size:9pt;"><a href="https://twitter.com/niwa_nz" title="" target="" style="font-family:Calibri;font-size:9pt;"><span style="font-family:Calibri; font-size:9pt;">Twitter</span></a></span><font style="font-family:Calibri;font-size:9pt;"> </font><span style="font-family:Calibri;font-size:9pt;"><a href="https://www.linkedin.com/company/niwa" title="" target="" style="font-family:Calibri;font-size:9pt;"><span style="font-family:Calibri; font-size:9pt;">LinkedIn</span></a></span><font style="font-family:Calibri;font-size:9pt;"> </font><span style="font-family:Calibri;font-size:9pt;"><a href="https://www.instagram.com/niwa_science" title="" target="" style="font-family:Calibri;font-size:9pt;"><span style="font-family:Calibri; font-size:9pt;">Instagram</span></a></span></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table class="ImprintUniqueIDTable" style="HEIGHT: 37px; VERTICAL-ALIGN: bottom; BORDER-COLLAPSE: collapse; TABLE-LAYOUT: auto; WIDTH: 933px" cellspacing="0" cellpadding="0" border="0">
<tbody>
</tbody>
</table>
<table class="ImprintUniqueIDTable" style="HEIGHT: 14px; VERTICAL-ALIGN: bottom; BORDER-COLLAPSE: collapse; TABLE-LAYOUT: auto; WIDTH: 933px" cellspacing="0" cellpadding="0" border="0">
<tbody>
</tbody>
</table>
<table class="ImprintUniqueIDTable" style="BORDER-COLLAPSE: collapse; WIDTH: 100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
</tbody>
</table>
<table class="ImprintUniqueIDTable" style="FONT-SIZE: x-small; FONT-FAMILY: Calibri; TABLE-LAYOUT: fixed" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td><font color="#244061" size="1" face="Calibri">
<table class="07b63f74-9868-4ae3-b533-9388a944d548Table">
<tbody>
<tr>
<td><font style="font-family:Calibri;font-size:7pt;color:#244061;"><font style="font-family:Calibri;font-size:8pt;color:#244061;">To ensure compliance with legal requirements and to maintain cyber security standards, NIWA's IT systems are subject to ongoing
 monitoring, activity logging and auditing. This monitoring and auditing service may be provided by third parties. Such third parties can access information transmitted to, processed by and stored on NIWA's IT systems.</font></font></td>
</tr>
</tbody>
</table>
</font></td>
</tr>
</tbody>
</table>
<br>
<table class="ImprintUniqueIDTable" style="BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" border="0">
<tbody>
</tbody>
</table>
<table class="ImprintUniqueIDTable" style="BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="500" border="0">
<tbody>
</tbody>
</table>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> postgis-users <postgis-users-bounces@lists.osgeo.org> on behalf of Sarthak Vijay <sarthak@attentive.ai><br>
<b>Sent:</b> Monday, May 27, 2019 22:57<br>
<b>To:</b> postgis-users@lists.osgeo.org<br>
<b>Subject:</b> [postgis-users] Counting intersecting polygons</font>
<div> </div>
</div>
<div>
<p class="ImprintUniqueID"></p>
<div style="border-top:#ffffff 1pt solid; border-right:medium none; border-bottom:medium none; padding-bottom:0cm; padding-top:3pt; padding-left:0cm; border-left:medium none; padding-right:0cm">
<p></p>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Hi All,</div>
<div dir="ltr">I have 2 tables containing polygons in same general area. What I want is the count of polygons in the first table (Table_1, represented by purple) that intersect with polygons in the 2nd (Table_2, represented by green). 
<div>
<div><img alt="Screenshot from 2019-05-23 13-33-24.png" width="542" height="193" src="cid:ii_jw0dktzu1"><br>
</div>
<div>For the above example, I want the output as 1. I have tried - </div>
<div>SELECT COUNT(*) FROM Table_1,Table_2 WHERE ST_Intersects(Table_1.wkb_geometry,Table_2.wkb_geometry);<br>
</div>
<div><br>
</div>
<div>This command returns the answer 3 which doesn't work for me.</div>
<div>Could someone please suggest relevant command.</div>
<div>Thanks in advance.</div>
<div><br>
</div>
<div>
<div><span style="font-family:arial,helvetica,sans-serif; color:rgb(136,136,136); font-size:12.8px">Regards,</span><br>
</div>
<div>
<div dir="ltr" class="m_-2085737487985395795gmail_signature">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div style="font-size:12.8px; color:rgb(136,136,136)">
<div><span style="font-family:arial,helvetica,sans-serif">Sarthak Vijay</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p></p>
<p></p>
<p></p>
</div>
</div>
<br>
<br>
<br>
<p></p>
</body>
</html>