Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Use latest() in where clause!




Is it possible to use the latest() function in a where clause? I get a strange error message when trying to do so.

Basically what I want to do is to select all sessions where the last analyticname for each sessionid is ABC.

SELECT latest(AnalyticName) from ApplicationUsageEvent WHERE latest(AnalyticName) = ‘ABC’ FACET SessionId since 1 weeks ago LIMIT 1000

I get an error message like "Not supported: Call{target=Id{name=‘latest’, isQuoted=false}, arguments=CallArguments{positionalArgs=[Id{name=‘AnalyticName’, isQuoted=false}], kwargs={}}} (at line 1 column 61) ".

If not possible is there a way to write the query in a different way to get what I’m looking for? I also tried to use it together with a filter() but it seems I cannot have the latest() in the where clause there either. If I just add the where clause to AnalyticsName=‘ABC’ I receive all sessions containing ABC and not only the once which have ABC as the latest item.

/Hans Börjesson


Hi @hans.borjesson - Unfortunately NRQL is not as powerful as SQL. Functions in a WHERE clause are not currently supported. Pop over to the post below and add your vote.


Hi @hans.borjesson! I hope Stefan’s explanation got you closer to where you need to be. Let us know what else you need! :blush:

Thanks for jumping in, @stefan_garnham!