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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...