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!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...