Skip to content

Instantly share code, notes, and snippets.

@aevdokimenko
Created September 27, 2018 19:37
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 aevdokimenko/2498a2ce677c544d3ceffbbcfd007024 to your computer and use it in GitHub Desktop.
Save aevdokimenko/2498a2ce677c544d3ceffbbcfd007024 to your computer and use it in GitHub Desktop.
Get stats on the cases in Salesforce using DBAmp + MS SQL
select
status, format(max(TTR), 'N') max,
format(min(TTR), 'N') min,
format(avg(TTR), 'N') avg
from (
select status, TTR = 1.0 * datediff(minute, createddate, isnull(closeddate, getdate()))/60
from openquery(salesforce,
'select status, createddate, closeddate
from case
where origin = ''GC'' and
createddate = LAST_N_DAYS:10'))t
group by status
order by status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment