Getting Data In

DB Connect: How to prevent append command from sorting columns in alphabetical order in the result set?

pramit46
Contributor

I have a query that looks like the following:
index=<> host=<> |rex=<> spath <>|table a,k,h|sort time|append[|dbquery DB "select X,Z,W,P from table_T where <> Order By time_col"]

the result set has the following columns:
a|k|h|P|W|X|Z
While I expect
a|k|h|X|Z|W|P

How can I get rid of this automatic alphabetical sorting?
While I run the dbquery alone, it works fine and shows me the expected columns.

1 Solution

russellliss
Path Finder

I have gotten around this before by using the table command, so in your example :

index= host= |rex= spath |table a,k,h|sort time|append[|dbquery DB "select X,Z,W,P from table_T where  Order By time_col"] | table a,k,h,X,Z,W,P

View solution in original post

russellliss
Path Finder

I have gotten around this before by using the table command, so in your example :

index= host= |rex= spath |table a,k,h|sort time|append[|dbquery DB "select X,Z,W,P from table_T where  Order By time_col"] | table a,k,h,X,Z,W,P

pramit46
Contributor

Thanks a lot @russellliss. This was really helpful

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...