<?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_clause in  arcpy.da.SearchCursor is NOT honoring &amp;quot;ORDER BY&amp;quot; in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51607#M4105</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your problem is this line:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;Out &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"in_memory/Selection"&lt;/SPAN&gt; ‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In-memory workspaces, both the legacy &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;in_memory&lt;/SPAN&gt; and newer &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;memory&lt;/SPAN&gt;, are not full-fledged geodatabases.&amp;nbsp; The newer &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;memory&lt;/SPAN&gt; workspace does support more geodatabase functionality than the older &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;in_memory, &lt;/SPAN&gt;but Esri doesn't clearly document all the improvements in the newer workspace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did some quick testing, and SQL ORDER BY is honored using the newer &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;memory&lt;/SPAN&gt; workspace.&amp;nbsp; If you aren't using ArcGIS Pro already, I encourage you to switch and also switch to using the newer in-memory workspace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See &lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/the-in-memory-workspace.htm" title="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/the-in-memory-workspace.htm"&gt;Write geoprocessing output to memory—ArcGIS Pro | Documentation&lt;/A&gt; :&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;H1 style="font-weight: 300; font-style: normal; margin: 0px 0px 1.55rem; font-size: 2.40307rem; line-height: 3.1rem; overflow-wrap: break-word;"&gt;Write geoprocessing output to memory&lt;/H1&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;Writing geoprocessing outputs to memory is an alternative to writing output to a geodatabase or file-based format. It is often significantly faster than writing to on-disk formats. Data written into memory is temporary and is deleted when the application is closed, so it is an ideal location to write intermediate data created in a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/what-is-modelbuilder-.htm" style="color: #0074b8; text-decoration: none;"&gt;ModelBuilder model&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/python-and-geoprocessing.htm" style="color: #0074b8; text-decoration: none;"&gt;Python script&lt;/A&gt;.&lt;/P&gt;&lt;H2 style="font-weight: 300; font-style: normal; margin: -145px 0px 1.55rem; font-size: 1.9994rem; line-height: 2.325rem; padding-top: 175px;"&gt;Memory-based workspaces&lt;/H2&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;ArcGIS provides two memory-based workspaces where geoprocessing outputs can be written.&lt;/P&gt;&lt;DIV class="" style="background-color: #ffffff; border: 1px solid #efefef; padding: 1.023rem; margin-bottom: 1.55rem;"&gt;&lt;H5 class="" style="font-weight: 300; font-style: normal; margin: 0px 0px 0rem; font-size: 1rem; line-height: 1.55rem;"&gt;Caution:&lt;/H5&gt;&lt;UL style="margin-top: 0px; margin-bottom: 1.55rem; padding: 0px; list-style-position: inside; margin-left: 0.775rem; font-size: 0.9375rem; line-height: 1.55rem;"&gt;&lt;LI style="list-style-position: outside; margin: 0.3875rem 0px 0.3875rem 1.5rem;"&gt;Memory-based workspaces do not support geodatabase elements such as feature datasets, representations, topologies, geometric networks, or network datasets.&lt;/LI&gt;&lt;LI style="list-style-position: outside; margin: 0.3875rem 0px 0.3875rem 1.5rem;"&gt;Folders cannot be created in memory-based workspaces.&lt;/LI&gt;&lt;LI style="list-style-position: outside; margin: 0.3875rem 0px 0.3875rem 1.5rem;"&gt;Since memory-based workspaces are stored in your system's physical memory, or RAM, your system may run low on memory if you write large datasets into the workspace. This can negatively impact processing performance.&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;H3 style="font-weight: 300; font-style: normal; margin: 0px 0px 1.55rem; font-size: 1.69949rem; line-height: 2.325rem;"&gt;memory&lt;/H3&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is a new memory-based workspace developed for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;ArcGIS Pro&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that supports output feature classes, tables, and raster datasets.&lt;/P&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;To write to the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;workspace, specify an output dataset path beginning with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;memory\&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and including no file extension—for example,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;memory\tempOutput&lt;/SPAN&gt;.&lt;/P&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;You can add&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;datasets to a map in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;ArcGIS Pro&lt;/SPAN&gt;.&lt;/P&gt;&lt;H3 style="font-weight: 300; font-style: normal; margin: 0px 0px 1.55rem; font-size: 1.69949rem; line-height: 2.325rem;"&gt;in_memory&lt;/H3&gt;&lt;DIV class="" style="background-color: #ffffff; border: 1px solid #efefef; padding: 1.023rem; margin-bottom: 1.55rem;"&gt;&lt;H5 class="" style="font-weight: 300; font-style: normal; margin: 0px 0px 0rem; font-size: 1rem; line-height: 1.55rem;"&gt;Legacy:&lt;/H5&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;in_memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is the legacy memory-based workspace built for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;ArcMap&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that supports output feature classes, tables, and raster datasets.&lt;/P&gt;&lt;/DIV&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;To write to the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;in_memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;workspace, specify an output dataset path beginning with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;in_memory\&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and including no file extension—for example,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;in_memory\tempOutput&lt;/SPAN&gt;.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 08 Aug 2020 21:10:02 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2020-08-08T21:10:02Z</dc:date>
    <item>
      <title>sql_clause in  arcpy.da.SearchCursor is NOT honoring "ORDER BY"</title>
      <link>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51603#M4101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on a script that is attempting to use ORDER BY. The results I'm seeing are unordered. I've dug quite a bit in GeoNet and elsewhere to no avail. My data is in a FGBD, my understanding is ORDER BY should work...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm hoping that there is something wrong with the logic in my script, and someone might help me identify it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;In a nutshell the script selects a group of features based on FEAT_SEQ, the selection is then sorted by a RANK field (NOT WORKING), the first row is then written to a new feature class. All of this is working except for the ordering. The output simply writes the first row, unsorted.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The&amp;nbsp;TableSelect, selects&amp;nbsp;features in a FC by the FEAT_SEQ field. The FEAT_SEQ is a result of the identify duplicate tool.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;UL&gt;&lt;LI&gt;This selection is intended to be "sorted" by the ORDER BY using the SearchCursor&lt;/LI&gt;&lt;LI&gt;Finally the first row is written to a new FC&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Seq_Count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#counter for FEAT_SEQ selection&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; range&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#loop - range 7631 (all)? for full run&lt;/SPAN&gt;
        Seq_Count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Seq_Count &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# adds 1 to Seq_Count&lt;/SPAN&gt;
        Where &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"FEAT_SEQ ="&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Seq_Count&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#sets sql expreassion to Seq_Count #&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;"Looping Seq &lt;SPAN class="comment token"&gt;#" + str(Seq_Count)) # prints Seq_Count # for ref. &lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TableSelect_analysis&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;DUPES&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Out&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Where&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# selects &lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;#print("Selection Complete - saved to cleanscript.gdb/SelSection") # loop done&lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;### load selection from previous output, evalute winner, save winner to winnigselection&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Out&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field_names &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fieldnames&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql_clause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;None&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'ORDER BY RANK'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; searchCursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#orders search by ranked&lt;/SPAN&gt;
                &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;InsertCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;winnerTable&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fieldnames&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; iCur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
                                        row &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;searchCursor&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#goes to first row (previouly ordered by rank)&lt;/SPAN&gt;
                                        &lt;SPAN class="comment token"&gt;#print(row)&lt;/SPAN&gt;
                                        iCur&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;insertRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
                                        &lt;SPAN class="comment token"&gt;#print("insert complete")&lt;/SPAN&gt;
                &lt;SPAN class="comment token"&gt;#del iCur #seems like you do this for housekeeping &lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;#del searchCursor #seems like you do this for housekeeping&lt;/SPAN&gt;
result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;winnerTable&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#counts output to winnerTable&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'{} has {} records'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;winnerTable&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#prints count‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The sql_clause is on line 9 (shown below)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Out&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field_names &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fieldnames&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql_clause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;None&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'ORDER BY RANK'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; searchCursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;screenshot of same code (in case it is easier to read)&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Same code from notepad++ if anyone prefers to view it tis way" class="jive-emoji image-1 jive-image j-img-original" src="/legacyfs/online/502767_Annotation 2020-08-07 163950.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for any insights anyone has to offer!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:59:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51603#M4101</guid>
      <dc:creator>WesleyGarrett1</dc:creator>
      <dc:date>2021-12-10T21:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: sql_clause in  arcpy.da.SearchCursor is NOT honoring "ORDER BY"</title>
      <link>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51604#M4102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you can share a subset of data, that is most helpful.&amp;nbsp; If not, can you create an example data set that generates the same behavior?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at the code, where is "Out" being defined?&amp;nbsp; And, for troubleshooting, take the loop out of it.&amp;nbsp; Get the code working with a single FEAT_SEQ and then introduce the loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Aug 2020 01:52:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51604#M4102</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-08-08T01:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: sql_clause in  arcpy.da.SearchCursor is NOT honoring "ORDER BY"</title>
      <link>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51605#M4103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Idea &lt;A href="https://community.esri.com/migrated-users/3420" target="_blank"&gt;Joshua Bixby&lt;/A&gt;‌. I've removed the loop and I'm seeing the same result. I'm attaching the GDB and the script. Lines 13, 18, and 20 will need to be re-pathed to your workspace to function. Out is defined in line 20.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/502768_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/502790_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see above for FEAT_SEQ = 1, the row rank 5 (the first row) is being written. If it were ordered I'd expect the values of 1 to be written, or 100 if it were somehow reversed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll put the code below as well for ref.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;#### Wesley Garrett - 20200715 &lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# script selects items based on feat_seq, exports to a feature class, that feature class is sorted and the top rank is selected &amp;amp; written to the winner feature class&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# used in modernization / label table to eliminate duplicate instances of fcsubtypes, chooses higheest ranked&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# duplicates must be indentified prior (using find identical tool) uses FEAT_SEQ&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# rank and rank field must be calculated / created prior (Expression_rank_fcsubtype_alltypes.cal) uses RANK (use python parser)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;######################&lt;/SPAN&gt;


&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Loading Arcpy..."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Setting Environment..."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcpy &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; env
env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"T:\FS\NFS\WOEngineering\GMO-GTAC\Project\DDC\Workspace\wdgarrett\roadsshield\cleanscript.gdb"&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;overwriteOutput &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"loading paths..."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
DUPES &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"T:\FS\NFS\WOEngineering\GMO-GTAC\Project\DDC\Workspace\wdgarrett\roadsshield\cleanscript.gdb\WRS_DUPE_JOINED2"&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# table to be clenaed &lt;/SPAN&gt;
Out &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"in_memory/Selection"&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#to improve speed&lt;/SPAN&gt;
winnerTable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"T:\FS\NFS\WOEngineering\GMO-GTAC\Project\DDC\Workspace\wdgarrett\roadsshield\cleanscript.gdb\winnerTable"&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# winner output (uses copy of Dupes to start) Schema of DUPES and winnerTable need to match&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#copies DUPES to winnerTable for output&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Copy_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;DUPES&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; winnerTable&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Copy for winnerTable"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
      
&lt;SPAN class="comment token"&gt;#clean winnerTable prior to run&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TruncateTable_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;winnerTable&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"winnerTable Cleared"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#get fields names and assign to fields&lt;/SPAN&gt;
dsc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;DUPES&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
fields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dsc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fields

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"DUPES Fields"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; field &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; dsc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"%-22s %s %s"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;":"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;type&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;#print field.name + " = " + field.type&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"WinnerTable Fields"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
dscwinner &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;winnerTable&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; field &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; dscwinner&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"%-22s %s %s"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;":"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;type&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;#print field.name + " = " + field.type&lt;/SPAN&gt;

out_fields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;dsc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;OIDFieldName&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dsc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;shapeFieldName&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#fields to not include this could include length etc. if not using tables &lt;/SPAN&gt;

fieldnames &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;!=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Shape'&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SHAPE@'&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; field &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fields &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; out_fields&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; 

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Out Fields"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;out_fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Field Names"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fieldnames&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

Seq_Count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;
Seq_Count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Seq_Count &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# adds 1 to Seq_Count&lt;/SPAN&gt;
Where &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"FEAT_SEQ ="&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Seq_Count&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#sets sql expreassion to Seq_Count #&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TableSelect_analysis&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;DUPES&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Out&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Where&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# selects &lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;### load selection from previous output, evalute winner, save winner to winnertable&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Out&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field_names &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fieldnames&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql_clause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;None&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'ORDER BY RANK'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; searchCursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#orders search by ranked&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;InsertCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;winnerTable&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fieldnames&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; iCur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        row &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;searchCursor&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#goes to first row (previouly ordered by rank)&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        iCur&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;insertRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
                                             
result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;winnerTable&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#counts output to winnerTable&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'{} has {} records'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;winnerTable&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#prints count&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"End / Done"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:59:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51605#M4103</guid>
      <dc:creator>WesleyGarrett1</dc:creator>
      <dc:date>2021-12-10T21:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: sql_clause in  arcpy.da.SearchCursor is NOT honoring "ORDER BY"</title>
      <link>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51606#M4104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am slightly at loss why you don't feed the SQL clause used in the "Table Select" tool directly into the &lt;STRONG&gt;arpy.da.SearchCursor&lt;/STRONG&gt;. If I am right, this should just work and give the same results, and maybe then the ORDER BY will work as well, as there is an actual SQL clause to combine it with.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Aug 2020 19:35:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51606#M4104</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2020-08-08T19:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: sql_clause in  arcpy.da.SearchCursor is NOT honoring "ORDER BY"</title>
      <link>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51607#M4105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your problem is this line:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;Out &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"in_memory/Selection"&lt;/SPAN&gt; ‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In-memory workspaces, both the legacy &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;in_memory&lt;/SPAN&gt; and newer &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;memory&lt;/SPAN&gt;, are not full-fledged geodatabases.&amp;nbsp; The newer &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;memory&lt;/SPAN&gt; workspace does support more geodatabase functionality than the older &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;in_memory, &lt;/SPAN&gt;but Esri doesn't clearly document all the improvements in the newer workspace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did some quick testing, and SQL ORDER BY is honored using the newer &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;memory&lt;/SPAN&gt; workspace.&amp;nbsp; If you aren't using ArcGIS Pro already, I encourage you to switch and also switch to using the newer in-memory workspace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See &lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/the-in-memory-workspace.htm" title="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/the-in-memory-workspace.htm"&gt;Write geoprocessing output to memory—ArcGIS Pro | Documentation&lt;/A&gt; :&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;H1 style="font-weight: 300; font-style: normal; margin: 0px 0px 1.55rem; font-size: 2.40307rem; line-height: 3.1rem; overflow-wrap: break-word;"&gt;Write geoprocessing output to memory&lt;/H1&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;Writing geoprocessing outputs to memory is an alternative to writing output to a geodatabase or file-based format. It is often significantly faster than writing to on-disk formats. Data written into memory is temporary and is deleted when the application is closed, so it is an ideal location to write intermediate data created in a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/what-is-modelbuilder-.htm" style="color: #0074b8; text-decoration: none;"&gt;ModelBuilder model&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/python-and-geoprocessing.htm" style="color: #0074b8; text-decoration: none;"&gt;Python script&lt;/A&gt;.&lt;/P&gt;&lt;H2 style="font-weight: 300; font-style: normal; margin: -145px 0px 1.55rem; font-size: 1.9994rem; line-height: 2.325rem; padding-top: 175px;"&gt;Memory-based workspaces&lt;/H2&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;ArcGIS provides two memory-based workspaces where geoprocessing outputs can be written.&lt;/P&gt;&lt;DIV class="" style="background-color: #ffffff; border: 1px solid #efefef; padding: 1.023rem; margin-bottom: 1.55rem;"&gt;&lt;H5 class="" style="font-weight: 300; font-style: normal; margin: 0px 0px 0rem; font-size: 1rem; line-height: 1.55rem;"&gt;Caution:&lt;/H5&gt;&lt;UL style="margin-top: 0px; margin-bottom: 1.55rem; padding: 0px; list-style-position: inside; margin-left: 0.775rem; font-size: 0.9375rem; line-height: 1.55rem;"&gt;&lt;LI style="list-style-position: outside; margin: 0.3875rem 0px 0.3875rem 1.5rem;"&gt;Memory-based workspaces do not support geodatabase elements such as feature datasets, representations, topologies, geometric networks, or network datasets.&lt;/LI&gt;&lt;LI style="list-style-position: outside; margin: 0.3875rem 0px 0.3875rem 1.5rem;"&gt;Folders cannot be created in memory-based workspaces.&lt;/LI&gt;&lt;LI style="list-style-position: outside; margin: 0.3875rem 0px 0.3875rem 1.5rem;"&gt;Since memory-based workspaces are stored in your system's physical memory, or RAM, your system may run low on memory if you write large datasets into the workspace. This can negatively impact processing performance.&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;H3 style="font-weight: 300; font-style: normal; margin: 0px 0px 1.55rem; font-size: 1.69949rem; line-height: 2.325rem;"&gt;memory&lt;/H3&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is a new memory-based workspace developed for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;ArcGIS Pro&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that supports output feature classes, tables, and raster datasets.&lt;/P&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;To write to the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;workspace, specify an output dataset path beginning with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;memory\&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and including no file extension—for example,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;memory\tempOutput&lt;/SPAN&gt;.&lt;/P&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;You can add&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;datasets to a map in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;ArcGIS Pro&lt;/SPAN&gt;.&lt;/P&gt;&lt;H3 style="font-weight: 300; font-style: normal; margin: 0px 0px 1.55rem; font-size: 1.69949rem; line-height: 2.325rem;"&gt;in_memory&lt;/H3&gt;&lt;DIV class="" style="background-color: #ffffff; border: 1px solid #efefef; padding: 1.023rem; margin-bottom: 1.55rem;"&gt;&lt;H5 class="" style="font-weight: 300; font-style: normal; margin: 0px 0px 0rem; font-size: 1rem; line-height: 1.55rem;"&gt;Legacy:&lt;/H5&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;in_memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is the legacy memory-based workspace built for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;ArcMap&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that supports output feature classes, tables, and raster datasets.&lt;/P&gt;&lt;/DIV&gt;&lt;P style="margin-top: 0px; margin-bottom: 1.55rem;"&gt;To write to the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;in_memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;workspace, specify an output dataset path beginning with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;in_memory\&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and including no file extension—for example,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, monospace;"&gt;in_memory\tempOutput&lt;/SPAN&gt;.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Aug 2020 21:10:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51607#M4105</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-08-08T21:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: sql_clause in  arcpy.da.SearchCursor is NOT honoring "ORDER BY"</title>
      <link>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51608#M4106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much! That was the problem. I switched to outputting to a GDB for the selection and everything worked as it should. Unfortunately I can't use Pro for this in the long run. We don't have the option at this time for enterprise applications.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good new though, it is working, albeit a little slower than it's already snails pace.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Aug 2020 14:06:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51608#M4106</guid>
      <dc:creator>WesleyGarrett1</dc:creator>
      <dc:date>2020-08-09T14:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: sql_clause in  arcpy.da.SearchCursor is NOT honoring "ORDER BY"</title>
      <link>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51609#M4107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I see a workflow using cursors in loops, more often than not there is a better/quicker workflow that leads to the same results.&amp;nbsp; If I understand what you are trying to do, it is very similar to what someone asked in &lt;A href="https://community.esri.com/thread/253928" target="_blank"&gt;Rank features by Field A for each unique value in Field B&lt;/A&gt; .&amp;nbsp; The code I provided in that thread was adapted from &lt;A href="https://community.esri.com/thread/194322" target="_blank"&gt;Deleting records from tabular intersect table based on 'PERCENTAGE' field&lt;/A&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made a copy of the &lt;CODE&gt;&lt;SPAN class=""&gt;WRS_DUPE_JOINED2&lt;/SPAN&gt;&lt;/CODE&gt; and ran the following code, which ran in a few seconds, and I think provides the results you are looking for here.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; UpdateCursor
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; itertools &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; groupby
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; operator &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; itemgetter

fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# path to feature class&lt;/SPAN&gt;
case_fields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"FEAT_SEQ"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
sort_field&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sort_dir &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"RANK"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ASC"&lt;/SPAN&gt;

sql_orderby &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ORDER BY {}, {} {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;", "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;case_fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    sort_field&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    sort_dir
&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; UpdateCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"*"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql_clause&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;None&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql_orderby&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    case_func &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; itemgetter&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
        &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;cur&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;index&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fld&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; fld &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; case_fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; key&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; group &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; groupby&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;cur&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; case_func&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        row &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;group&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; group&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            cur&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;deleteRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:59:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51609#M4107</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-10T21:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: sql_clause in  arcpy.da.SearchCursor is NOT honoring "ORDER BY"</title>
      <link>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51610#M4108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Josh! I'll give that a try.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Aug 2020 17:44:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51610#M4108</guid>
      <dc:creator>WesleyGarrett1</dc:creator>
      <dc:date>2020-08-09T17:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: sql_clause in  arcpy.da.SearchCursor is NOT honoring "ORDER BY"</title>
      <link>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51611#M4109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow! That ran in ~10 seconds. A much better solution. I had been running my version prior, after 2.5 hours it had barely broken 1000 records. I would have been waiting 500+ hours (20 days).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Much appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Aug 2020 18:21:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-clause-in-arcpy-da-searchcursor-is-not/m-p/51611#M4109</guid>
      <dc:creator>WesleyGarrett1</dc:creator>
      <dc:date>2020-08-09T18:21:04Z</dc:date>
    </item>
  </channel>
</rss>

