<?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: Does sort like &amp;quot;order by&amp;quot; in sql for list of fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586210#M204200</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/239472"&gt;@Jackiifilwhh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you should see the sort command at&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/SortCommandExamples" target="_blank"&gt;https://docs.splunk.com/Documentation/SCS/current/SearchReference/SortCommandExamples&lt;/A&gt;&lt;/P&gt;&lt;P&gt;you can use the sort command adding a field and not a function, to have the desc, you have to use "-".&lt;/P&gt;&lt;P&gt;in your case&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sort no -time&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Feb 2022 12:16:49 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2022-02-23T12:16:49Z</dc:date>
    <item>
      <title>Does sort like "order by" in sql for list of fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586209#M204199</link>
      <description>&lt;P&gt;Hi, I'm new to Splunk. The question I want to ask is does sort like "order by" in sql for list of fields, which&amp;nbsp;&lt;SPAN&gt;divide into groups first and then sort within group. For example :&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE border="1" width="60%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;no&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="47px"&gt;1&lt;/TD&gt;
&lt;TD height="47px"&gt;2022-01-22 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="47px"&gt;2&lt;/TD&gt;
&lt;TD width="50%" height="47px"&gt;2022-01-20 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="47px"&gt;2&lt;/TD&gt;
&lt;TD width="50%" height="47px"&gt;2022-01-26 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="47px"&gt;1&lt;/TD&gt;
&lt;TD width="50%" height="47px"&gt;2022-01-21 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;When in sql, using command "order by no, time desc", the result is like this :&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;no&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="47px"&gt;1&lt;/TD&gt;
&lt;TD height="47px"&gt;2022-01-22 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="47px"&gt;1&lt;/TD&gt;
&lt;TD width="50%" height="47px"&gt;2022-01-21 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="47px"&gt;2&lt;/TD&gt;
&lt;TD width="50%" height="47px"&gt;2022-01-26 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="47px"&gt;2&lt;/TD&gt;
&lt;TD width="50%" height="47px"&gt;2022-01-20 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in SPL, when I use command "sort str(no), -str(time)", the result is this :&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;no&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="47px"&gt;2&lt;/TD&gt;
&lt;TD height="47px"&gt;2022-01-26 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="47px"&gt;1&lt;/TD&gt;
&lt;TD width="50%" height="47px"&gt;2022-01-22 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="47px"&gt;1&lt;/TD&gt;
&lt;TD width="50%" height="47px"&gt;2022-01-21 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="47px"&gt;2&lt;/TD&gt;
&lt;TD width="50%" height="47px"&gt;2022-01-20 18:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is sort different from order by in sql or just my command is wrong? Thank you very much for answering my question!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 18:39:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586209#M204199</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2022-02-23T18:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Does sort like "order by" in sql for list of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586210#M204200</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/239472"&gt;@Jackiifilwhh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you should see the sort command at&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/SortCommandExamples" target="_blank"&gt;https://docs.splunk.com/Documentation/SCS/current/SearchReference/SortCommandExamples&lt;/A&gt;&lt;/P&gt;&lt;P&gt;you can use the sort command adding a field and not a function, to have the desc, you have to use "-".&lt;/P&gt;&lt;P&gt;in your case&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sort no -time&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 12:16:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586210#M204200</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-02-23T12:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Does sort like "order by" in sql for list of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586212#M204202</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you very much!&lt;/P&gt;&lt;P&gt;sort is same as "order by" and I know why it seems doesn't work firstly&lt;/P&gt;&lt;P&gt;I use command "table" first and then use "sort", so it won't work!&lt;/P&gt;&lt;P&gt;when I reverse these two commands, it worked successfully!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 12:39:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586212#M204202</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2022-02-23T12:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Does sort like "order by" in sql for list of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586215#M204203</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/239472"&gt;@Jackiifilwhh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Can you try using the field directly in the sort function instead of converting it to string? Although, you will need to convert time to string using time converter functions. Below is the sample query you can try out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Time=strftime(time, "%Y-%m-%d %H:%M:%S.%Q") 
| table no Time
| sort no - Time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 12:45:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586215#M204203</guid>
      <dc:creator>tshah-splunk</dc:creator>
      <dc:date>2022-02-23T12:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Does sort like "order by" in sql for list of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586217#M204204</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229101"&gt;@tshah-splunk&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you and it worked finally by using table command after sort!&lt;/P&gt;&lt;P&gt;the truth is sort is same as order by in sql!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 12:49:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586217#M204204</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2022-02-23T12:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Does sort like "order by" in sql for list of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586219#M204206</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/239472"&gt;@Jackiifilwhh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;at first put attention to the field names: the are case sensitive ("Time" is different by "time") and if you're using the rename command you have to use the renamed fieldname.&lt;/P&gt;&lt;P&gt;In addition, to have a descendant order, you have to put the "-" attached to the field without spaces, in other words:&lt;/P&gt;&lt;P&gt;|&amp;nbsp; sort - time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;isn't correct&lt;/P&gt;&lt;P&gt;| sort -time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;is correct&lt;/P&gt;&lt;P&gt;If you could share your search I could check it.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the Contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 13:01:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586219#M204206</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-02-23T13:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Does sort like "order by" in sql for list of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586223#M204210</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my search. Btw, my Splunk's version is 8.1.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval time=strftime(_time,"%Y-%m-%d %H:%M:%S.%Q") | sort 0 no, -time | table no time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 13:21:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586223#M204210</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2022-02-23T13:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Does sort like "order by" in sql for list of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586226#M204211</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/239472"&gt;@Jackiifilwhh&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;when you want to sort for a date or a time, it's always better to sort in epochtime, in other words change the order of your commands.&lt;/P&gt;&lt;P&gt;In addition don't use comma in sort command.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sort 0 no -_time 
| eval time=strftime(_time,"%Y-%m-%d %H:%M:%S.%Q") 
| table no time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 13:24:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586226#M204211</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-02-23T13:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Does sort like "order by" in sql for list of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586229#M204212</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well, thank you! This is really a better way&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 13:28:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-sort-like-quot-order-by-quot-in-sql-for-list-of-fields/m-p/586229#M204212</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2022-02-23T13:28:44Z</dc:date>
    </item>
  </channel>
</rss>

