Splunk Search

How do I divide data in a field by a certain value?

BobKimata
Path Finder

I have a search based on an SQL query e.g. select * from . I would like to divide some data displayed on a field called 'Cost' by 2 and display result on the same field. I only have one row of data.

Thanks

Tags (1)
0 Karma
1 Solution

Flynt
Splunk Employee
Splunk Employee

add |eval Cost=Cost/2 after your SQL search

View solution in original post

Flynt
Splunk Employee
Splunk Employee

add |eval Cost=Cost/2 after your SQL search

BobKimata
Path Finder

I did that but receive this error:
command="dbquery", A database error occurred: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '|eval Cost=Cost/2' at line 1.

The sql query works fine without the expression.

0 Karma

Flynt
Splunk Employee
Splunk Employee

Can you give the whole syntax for your search? The |eval Cost=Cost/2 is a Splunk function and would need to exist outside of any dbquery commands.

0 Karma

BobKimata
Path Finder

I got it working. I had forgotten to put the SQL query in quotes. Thanks

0 Karma

Flynt
Splunk Employee
Splunk Employee

Excellent! Please accept if the answer was helpful.

0 Karma
Get Updates on the Splunk Community!

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...

Updated Data Management and AWS GDI Inventory in Splunk Observability

We’re making some changes to Data Management and Infrastructure Inventory for AWS. The Data Management page, ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...