<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SQL in &amp;quot;Extract by Attributes&amp;quot;  Conditional Where Clause in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606893#M34183</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Wayne,&lt;/P&gt;&lt;P&gt;thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I have never programmed anything bevor it is most likely that I have made a blunder somewhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The entire input is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT*FROM LCall.tif.vat WHERE:&amp;nbsp;&amp;nbsp; (This is already provided by the "Select by Attributes tool") ((Yes, Within the Spatial Analyst / Select by Attributes in the Attribute Table Window)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN&gt;( NOT "2003"=3 AND NOT "2006" =3 AND "2011"=3 )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN&gt;AND&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"1984"&lt;/SPAN&gt;&lt;SPAN&gt; =1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"1986"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; +&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"1987"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"1991"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"2000"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"2003"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"2006"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; +&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"2011"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;gt;= 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expression before the following CASE WHEN.... is working on ist own. Also it is only one of a total of 6 different expressions I have already programmed and that work as intended.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this claryfies things. Again thanks allot!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Tabel is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="python" style="display: none;"&gt;&amp;gt;&amp;gt;&amp;gt; where_clause = '(CASE WHEN "1984" =1 THEN 1 ELSE 0 END + CASE WHEN "1986" = 1 THEN 1 ELSE 0 END + CASE WHEN "1987" = 1 THEN 1 ELSE 0 END + CASE WHEN "1991" = 1 THEN 1 ELSE 0 END + CASE WHEN "2000" = 1 THEN 1 ELSE 0 END + CASE WHEN "2003" = 1 THEN 1 ELSE 0 END + CASE WHEN "2006" = 1 THEN 1 ELSE 0 END + CASE WHEN "2011" = 1 THEN 1 ELSE 0 END) &amp;gt;= 3'
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; print where_clause
(CASE WHEN "1984" =1 THEN 1 ELSE 0 END + CASE WHEN "1986" = 1 THEN 1 ELSE 0 END + CASE WHEN "1987" = 1 THEN 1 ELSE 0 END + CASE WHEN "1991" = 1 THEN 1 ELSE 0 END + CASE WHEN "2000" = 1 THEN 1 ELSE 0 END + CASE WHEN "2003" = 1 THEN 1 ELSE 0 END + CASE WHEN "2006" = 1 THEN 1 ELSE 0 END + CASE WHEN "2011" = 1 THEN 1 ELSE 0 END) &amp;gt;= 3
&amp;gt;&amp;gt;&amp;gt; 

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 880px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="20" style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;OID&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;VALUE&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;COUNT&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;1984&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;1986&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;1987&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;1991&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;2000&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;2003&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;2006&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium medium 1.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;2011&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;0&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;58461228&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium medium 0.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;2&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;181039&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;4&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium medium 0.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;2&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;2692&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium medium 0.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;4&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;686&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;4&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium medium 0.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;4&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;5&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;377228&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium medium 0.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;5&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;6&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3109&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Jul 2014 09:19:55 GMT</pubDate>
    <dc:creator>CarolineSchneider</dc:creator>
    <dc:date>2014-07-22T09:19:55Z</dc:date>
    <item>
      <title>SQL in "Extract by Attributes"  Conditional Where Clause</title>
      <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606889#M34179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to apply an SQL-funktion within the "Extract by Attributes"-Tool of ArcGIS.&lt;/P&gt;&lt;P&gt;I have a Table of 27.000 rows and 2+8 columns. I would like to select only those rows, where the event field=1 happens only 3 times in all. Values within those columns are 1, 2, 3 or 4.&lt;/P&gt;&lt;P&gt;The tool already provides the select funktion part, there after:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;CASE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;"1984"&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;THEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;END&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;AND&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;CASE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;"1986"&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;THEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;END&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;AND&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;CASE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;"1987"&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;THEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;END&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;AND&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;CASE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;"1991"&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;THEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;END&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;AND&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;CASE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;"2000"&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;THEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;END&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;AND&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;CASE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;"2003"&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;THEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;END&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;AND&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;CASE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;"2006"&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;THEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;END&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;AND&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;CASE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;"2011"&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;THEN&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;END&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;3&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SQL statment is not excepted by the ArcGIS-tool. So something must be wrong here.&lt;/P&gt;&lt;P&gt;Greatefull for any ideas!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 10:36:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606889#M34179</guid>
      <dc:creator>CarolineSchneider</dc:creator>
      <dc:date>2014-07-21T10:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: SQL in "Extract by Attributes"  Conditional Where Clause</title>
      <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606890#M34180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks to me, if I understand correctly your logic, you are simply missing the plus operator, like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14059719604584018" jivemacro_uid="_14059719604584018"&gt;
&lt;P&gt;(CASE WHEN "1984" =1 THEN 1 ELSE 0 END +&lt;/P&gt;
&lt;P&gt;CASE WHEN "1986" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;
&lt;P&gt;CASE WHEN "1987" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;
&lt;P&gt;CASE WHEN "1991" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;
&lt;P&gt;CASE WHEN "2000" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;
&lt;P&gt;CASE WHEN "2003" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;
&lt;P&gt;CASE WHEN "2006" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;
&lt;P&gt;CASE WHEN "2011" = 1 THEN 1 ELSE 0 END)&lt;/P&gt;
&lt;P&gt;&amp;gt;= 3&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;



&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All you need is for the entire query to return True or False...but the way you have it set up testing each field conditionally, each field tested for the numeric value 1 will individually test True or False -- if True, you are assigning a value of 1, so if you want to test whether at least 3 of them eval to 1 then you have to add their respective results together.&amp;nbsp; Looks like you had a little mistake toward the end too with 'THEN ELSE' (no value assigned for THEN).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh, almost forgot, when you use the 'AND', you're not adding...that would check for something like TRUE AND TRUE AND FALSE which would then be FALSE for the whole thing (wouldn't make sense to compare to 3).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Wayne&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS-&amp;nbsp; I suppose another example could be useful - certainly not the only way to run such a query, but this one applies similar SQL logic to select parcels in a subarea (by Township and Range) that are not coded (partial string) VACANT in a LOCATION field - this is Python using a SQL query in the SelectLayerByAttribute tool:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14059736118095626" jivemacro_uid="_14059736118095626" modifiedtitle="true"&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; qry = '(CASE WHEN "RNG" &amp;gt;= 32 AND "RNG" &amp;lt;= 35 THEN 1 ELSE 0 END + CASE WHEN "TWP" &amp;gt;= 62 AND "TWP" &amp;lt;= 66 THEN 1 ELSE 0 END + CASE WHEN "LOCATION" LIKE \'%VACANT%\' THEN 0 ELSE 1 END) = 3'&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; arcpy.SelectLayerByAttribute_management("parcels20140102", "NEW_SELECTION", qry)&lt;/P&gt;
&lt;P&gt;&amp;lt;Result 'parcels20140102'&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 19:53:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606890#M34180</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2014-07-21T19:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: SQL in "Extract by Attributes"  Conditional Where Clause</title>
      <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606891#M34181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Wayne,&lt;/P&gt;&lt;P&gt;thanks, your suggestions are absolutely plausable.&lt;/P&gt;&lt;P&gt;I have corrected those mistakes and tried to run the algorithm again, but ArcGIS still states that there is a wrong SQL statement somewhere.&lt;/P&gt;&lt;P&gt;Do you happen to have any further thoughts on this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for helping out!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Cheers Caro &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 20:16:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606891#M34181</guid>
      <dc:creator>CarolineSchneider</dc:creator>
      <dc:date>2014-07-21T20:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: SQL in "Extract by Attributes"  Conditional Where Clause</title>
      <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606892#M34182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could be a simple mistake, can you post a picture or code block if that is how you're running it?&amp;nbsp; Also, what version ArcGIS are you using and what DB platform are you running against?&amp;nbsp; You are using the Spatial Analyst tool, correct?&amp;nbsp; (although that should not matter - should accept SQL)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As an initial guess, I think maybe you're not passing the query to the tool as a string - for example, when I run in Python a similar kind of SQL, notice it is a string (here I'm entering the backslash line continuation character for better readability):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14059746538521043" jivemacro_uid="_14059746538521043"&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;gt;&amp;gt;&amp;gt; qry = '(CASE WHEN "RNG" &amp;gt;= 32 AND "RNG" &amp;lt;= 35 THEN 1 ELSE 0 END + \&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CASE WHEN "TWP" &amp;gt;= 62 AND "TWP" &amp;lt;= 66 THEN 1 ELSE 0 END + \&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CASE WHEN "LOCATION" LIKE \'%VACANT%\' THEN 0 ELSE 1 END) = 3'&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;gt;&amp;gt;&amp;gt; fc = r'C:\Users\whitley-wayne\Desktop\data_backup05131551.gdb\parcels20140102'&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;gt;&amp;gt;&amp;gt; arcpy.MakeFeatureLayer_management(fc, 'testLyr', qry)&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;lt;Result 'testLyr'&amp;gt;&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal"&gt;&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;gt;&amp;gt;&amp;gt; theCount = arcpy.GetCount_management('testLyr')&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;gt;&amp;gt;&amp;gt; theCount.getOutput(0)&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;u'9485'&lt;/P&gt;
&lt;P class="yiv4570371402MsoNormal" style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your query string is fairly long, but I see nothing wrong with passing it as a single-line string, for example:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14059750123614552 jive_text_macro" jivemacro_uid="_14059750123614552"&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; where_clause = '(CASE WHEN "1984" =1 THEN 1 ELSE 0 END + CASE WHEN "1986" = 1 THEN 1 ELSE 0 END + CASE WHEN "1987" = 1 THEN 1 ELSE 0 END + CASE WHEN "1991" = 1 THEN 1 ELSE 0 END + CASE WHEN "2000" = 1 THEN 1 ELSE 0 END + CASE WHEN "2003" = 1 THEN 1 ELSE 0 END + CASE WHEN "2006" = 1 THEN 1 ELSE 0 END + CASE WHEN "2011" = 1 THEN 1 ELSE 0 END) &amp;gt;= 3'&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; print where_clause&lt;/P&gt;
&lt;P&gt;(CASE WHEN "1984" =1 THEN 1 ELSE 0 END + CASE WHEN "1986" = 1 THEN 1 ELSE 0 END + CASE WHEN "1987" = 1 THEN 1 ELSE 0 END + CASE WHEN "1991" = 1 THEN 1 ELSE 0 END + CASE WHEN "2000" = 1 THEN 1 ELSE 0 END + CASE WHEN "2003" = 1 THEN 1 ELSE 0 END + CASE WHEN "2006" = 1 THEN 1 ELSE 0 END + CASE WHEN "2011" = 1 THEN 1 ELSE 0 END) &amp;gt;= 3&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 20:31:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606892#M34182</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2014-07-21T20:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: SQL in "Extract by Attributes"  Conditional Where Clause</title>
      <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606893#M34183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Wayne,&lt;/P&gt;&lt;P&gt;thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I have never programmed anything bevor it is most likely that I have made a blunder somewhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The entire input is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT*FROM LCall.tif.vat WHERE:&amp;nbsp;&amp;nbsp; (This is already provided by the "Select by Attributes tool") ((Yes, Within the Spatial Analyst / Select by Attributes in the Attribute Table Window)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN&gt;( NOT "2003"=3 AND NOT "2006" =3 AND "2011"=3 )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN&gt;AND&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"1984"&lt;/SPAN&gt;&lt;SPAN&gt; =1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"1986"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; +&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"1987"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"1991"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"2000"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"2003"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"2006"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt; +&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar"&gt;&lt;SPAN&gt;&lt;SPAN class="func"&gt;CASE&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="string"&gt;"2011"&lt;/SPAN&gt;&lt;SPAN&gt; = 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;THEN&lt;/SPAN&gt;&lt;SPAN&gt; 1 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;ELSE&lt;/SPAN&gt;&lt;SPAN&gt; 0 &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;END&lt;/SPAN&gt;&lt;SPAN&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;gt;= 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expression before the following CASE WHEN.... is working on ist own. Also it is only one of a total of 6 different expressions I have already programmed and that work as intended.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this claryfies things. Again thanks allot!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Tabel is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="python" style="display: none;"&gt;&amp;gt;&amp;gt;&amp;gt; where_clause = '(CASE WHEN "1984" =1 THEN 1 ELSE 0 END + CASE WHEN "1986" = 1 THEN 1 ELSE 0 END + CASE WHEN "1987" = 1 THEN 1 ELSE 0 END + CASE WHEN "1991" = 1 THEN 1 ELSE 0 END + CASE WHEN "2000" = 1 THEN 1 ELSE 0 END + CASE WHEN "2003" = 1 THEN 1 ELSE 0 END + CASE WHEN "2006" = 1 THEN 1 ELSE 0 END + CASE WHEN "2011" = 1 THEN 1 ELSE 0 END) &amp;gt;= 3'
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; print where_clause
(CASE WHEN "1984" =1 THEN 1 ELSE 0 END + CASE WHEN "1986" = 1 THEN 1 ELSE 0 END + CASE WHEN "1987" = 1 THEN 1 ELSE 0 END + CASE WHEN "1991" = 1 THEN 1 ELSE 0 END + CASE WHEN "2000" = 1 THEN 1 ELSE 0 END + CASE WHEN "2003" = 1 THEN 1 ELSE 0 END + CASE WHEN "2006" = 1 THEN 1 ELSE 0 END + CASE WHEN "2011" = 1 THEN 1 ELSE 0 END) &amp;gt;= 3
&amp;gt;&amp;gt;&amp;gt; 

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 880px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="20" style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;OID&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;VALUE&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;COUNT&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;1984&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;1986&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;1987&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;1991&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;2000&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;2003&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium 0.5pt 1.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;2006&lt;/TD&gt;&lt;TD style="background: #4f81bd; border-width: medium medium 1.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: white; font-family: Calibri; font-size: 11pt; font-weight: bold;" width="80"&gt;2011&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;0&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;58461228&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium medium 0.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;2&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;181039&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;4&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium medium 0.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;2&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;2692&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium medium 0.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;4&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;686&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;4&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium medium 0.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;4&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;5&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;377228&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium 0.5pt 0.5pt medium; border-style: none solid solid none; border-color: currentColor white white currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #b8cce4; border-width: medium medium 0.5pt; border-style: none none solid; border-color: currentColor currentColor white; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;5&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;6&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3109&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; border-width: medium 0.5pt medium medium; border-style: none solid none none; border-color: currentColor white currentColor currentColor; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;1&lt;/TD&gt;&lt;TD align="right" style="background: #dbe5f1; color: black; font-family: Calibri; font-size: 11pt; font-weight: 400;"&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2014 09:19:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606893#M34183</guid>
      <dc:creator>CarolineSchneider</dc:creator>
      <dc:date>2014-07-22T09:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: SQL in "Extract by Attributes"  Conditional Where Clause</title>
      <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606894#M34184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Caroline,&lt;/P&gt;&lt;P&gt;You haven't answered the specifics of your error - are you still having the 'invalid SQL statement' error?&amp;nbsp; Also, you didn't say what version of ArcGIS and db source you're using (or I missed it).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, for what it's worth, you have to be careful with your logic and your statement is getting pretty long, perhaps convoluted.&amp;nbsp; Consider this, with my above SQL query example - similar to yours, I am combining clauses that all must eval to True to select the record, that is everything within the 'compound' clause and everything without as well.&amp;nbsp; That means when you connect with 'AND' 1 clause you know works to another clause, both must evaluate to True to make the selection.&amp;nbsp; See this, which for my dataset only selected a single record (to illustrate the concept):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(NOT "RNG" = 33 AND NOT "RNG" = 34 AND&amp;nbsp; "TWP" = 62)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(CASE WHEN "RNG" &amp;gt;= 32 AND "RNG" &amp;lt;= 35 THEN 1 ELSE 0 END +&lt;/P&gt;&lt;P&gt; CASE WHEN "TWP" &amp;gt;= 62 AND "TWP" &amp;lt;= 66 THEN 1 ELSE 0 END +&lt;/P&gt;&lt;P&gt; CASE WHEN "LOCATION" LIKE '%VACANT%' THEN 0 ELSE 1 END) = 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is because not only does the 2nd clause (= 3) have to be satisfied, but so does the 1st.&amp;nbsp; It must not contain those records where the range is 33 nor 34.&amp;nbsp; Not only that but with '...AND "TWP" = 62', that restricts the entire results to the township coded 62 only.&amp;nbsp; So if your SQL is not in error (the above query works at 10.2.1), then check your logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Wayne&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2014 15:37:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606894#M34184</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2014-07-22T15:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: SQL in "Extract by Attributes"  Conditional Where Clause</title>
      <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606895#M34185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Wayne,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the 10.1 version of ArcGIS. The statment is still invalid.&lt;/P&gt;&lt;P&gt;I am quite sure that there is no Problem wih my logic. I have a data base of 27,000 rows and eight columns of interesst. Each field can only have one of the following numbers: 1,2,3,4&lt;/P&gt;&lt;P&gt;The db file Ends tif.vat. I am not sure if this is all the Information you need on the db.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the problem lies in the CASE WHEN- expression&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(CASE WHEN "1984"= 1 THEN 1 ELSE 0 END +&lt;/P&gt;&lt;P&gt;CASE WHEN "1986" =1 THEN 1 ELSE 0 END) = 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I would type in this single Expression, should it work? ArcGIS notes: an invalid SQL statment was used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for your help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Caroline&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 08:00:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606895#M34185</guid>
      <dc:creator>CarolineSchneider</dc:creator>
      <dc:date>2014-07-23T08:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: SQL in "Extract by Attributes"  Conditional Where Clause</title>
      <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606896#M34186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is some vague reference to &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s500000033000000"&gt;subqueries not being supported&lt;/A&gt; mid-way down&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Subqueries&lt;/H2&gt;&lt;DIV class="note"&gt;&lt;IMG alt="Note" class="jive-image note_img" src="http://resources.arcgis.com/en/help/main/10.2/rsrc/note.png" title="Note" /&gt;Note:&lt;P&gt;&lt;/P&gt;&lt;P&gt;Coverages, shapefiles, and other nongeodatabase file-based data sources do not support subqueries. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you simplify your query to one condition then see if you can build upon it?&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 08:25:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606896#M34186</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-07-23T08:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: SQL in "Extract by Attributes"  Conditional Where Clause</title>
      <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606898#M34188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Wayne, &lt;BR /&gt;hello Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for your support on this!&lt;/P&gt;&lt;P&gt;I have tried to calculate the "dummy"-field in arcgis via python, but did not succeed. So instead i did the same thing in open office and then I reintroduced those values into the table by using a table join.&lt;BR /&gt;It's not as elegant as your suggestion Wayne, but I got there anyway.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So thanks again,&lt;/P&gt;&lt;P&gt;Caro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 09:32:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606898#M34188</guid>
      <dc:creator>CarolineSchneider</dc:creator>
      <dc:date>2014-08-05T09:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: SQL in "Extract by Attributes"  Conditional Where Clause</title>
      <link>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606897#M34187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are correct (and so is Dan).&amp;nbsp; Based on your results, the problem is with the CASE statement.&amp;nbsp; I tested the same datasource (file gdb) at both 10.0 and 10.2.1 -- the 10.0 test failed with the file gdb source but passed with an sde source; no problems at all with 10.2.1.&amp;nbsp; So what I suggest to help make this easier on yourself is (if you can) calculate a new 'dummy' field (integer type) just to hold this CASE result, conditionally calculating the 2nd compound clause, this part:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(CASE WHEN "1984" =1 THEN 1 ELSE 0 END +&lt;/P&gt;&lt;P&gt;CASE WHEN "1986" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;&lt;P&gt;CASE WHEN "1987" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;&lt;P&gt;CASE WHEN "1991" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;&lt;P&gt;CASE WHEN "2000" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;&lt;P&gt;CASE WHEN "2003" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;&lt;P&gt;CASE WHEN "2006" = 1 THEN 1 ELSE 0 END +&lt;/P&gt;&lt;P&gt;CASE WHEN "2011" = 1 THEN 1 ELSE 0 END)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should be able to do that with, say, a simple Python code block in the field calculator, something simple like the below - there's a less tedious way to write this function in more condensed 'pythonic' form, but this way you can more readily see what it's doing - this is the code block:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

def subQry(yr84, yr86, yr87, yr91, yr00, yr03, yr06, yr11):


&amp;nbsp; counter = 0


&amp;nbsp; if yr84 == 1:


&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1


&amp;nbsp; if yr86 == 1:


&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1


&amp;nbsp; if yr87 == 1:


&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1


&amp;nbsp; if yr91 == 1:


&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1


&amp;nbsp; if yr00 == 1:


&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1


&amp;nbsp; if yr03 == 1:


&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1


&amp;nbsp; if yr06 == 1:


&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1


&amp;nbsp; if yr11 == 1:


&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1


&amp;nbsp; return counter





&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...and of course in the field calculator you'd check on the Python parser, and enter this expression statement to pass your fields:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;subQry(!1984!, !1986!, !1987!, !1991!, !2000!, !2003!, !2006!, !2011!)





&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, say your 'dummy' field is called 'yourNewField', then your new SQL query based on this calculation should be valid (oops, previously I forgot the double-quote delimiters on "yourNewField", now corrected):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOT "2003"=3 AND NOT "2006" =3 AND "2011"=3 AND "yourNewField" &amp;gt;= 3&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:00:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/sql-in-quot-extract-by-attributes-quot-conditional/m-p/606897#M34187</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-12T02:00:08Z</dc:date>
    </item>
  </channel>
</rss>

