Skip to content

Instantly share code, notes, and snippets.

@lyonanderson
Created July 10, 2015 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyonanderson/6140eced0dca514b3388 to your computer and use it in GitHub Desktop.
Save lyonanderson/6140eced0dca514b3388 to your computer and use it in GitHub Desktop.
SELECT sum(cpu_seconds) FROM
( SELECT case when diff_raw < -10 then value else diff_raw end as cpu_seconds
FROM ( SELECT *, value - prevVal as diff_raw FROM ( SELECT ID, ProcessName, value, ( SELECT t2.value FROM PLProcessMonitorAgent_EventBackward_ProcessMonitor_Dynamic t2 where t2.ID < t1.ID and ProcessName == "kernel_task" order by t2.ID desc limit 1 ) as prevVal FROM PLProcessMonitorAgent_EventBackward_ProcessMonitor_Dynamic t1 WHERE ProcessName == "kernel_task" ) ) WHERE cpu_seconds IS NOT NULL )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment