Perform math (minus) across event types

This is a follow up to Can I perform math (sum, divide, etc) across multiple event types?

Is it possible to perform such kind of a query?

SELECT event_type_1.timestamp - event_type_2.timestamp from event_type_1, event_type_2 ON event_type_1.unique_id = event_type_2.unique_id

AFAIK, we can facet on an attribute or use the filter function on attributes but I do not know if this kind of JOIN is supported.

Hey @saleem.majeeth

You can’t do your Join like: ON event_type_1.unique_id = event_type_2.unique_id

BUT, you can do math on different events using dot notation as you do in your example. Here’s a example of that:

SELECT average(PageView.duration) as 'PageView', average(Transaction.duration) as 'Transaction', (average(PageView.duration) - average(Transaction.duration)) as 'PageView-Transaction' FROM Transaction, PageView SINCE TODAY

1 Like

Yeah, this gives us an aggerate result which is different from a “join” based result where we get “rows” for every join key. I am interested in getting rows from two event types that match a join key.

I guess the only way to achieve this kind of result is to create a single event type with all the details from event_type_1 and event_type_2

You could potentially programmatically handle this through New Relic Custom Visualisations.

Custom Visualisations are custom react apps that sit on top of your New Relic account that you can add to your dashboards.

Within a Custom Viz you could pull the data out from both events and analyse/visualise the data any way you wish.

See here:

1 Like