---
schema_version: "1"
id: f2bbbfa2d6c258b910556fc159e9fc763a247340546c2aeb7dea760ae774de84
title: "Example: Cases Closed by Interaction Type"
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ai/264-0-0/search_es_case_closure_exp1.md
canonical_url: https://help.salesforce.com/s/articleView?id=ai.search_es_case_closure_exp1.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: f71790ce12b380437382562e948c542d8c37b1d7a4928920822f596aeee4b3d8
description: Use this example SQL for percent and total cases closed by interaction type.
products:
  - Cross Cloud
release: "264"
---
# Example: Cases Closed by Interaction Type

Use this example SQL for percent and total cases closed by interaction type.

In this example, replace the bolded text with the API field names of your case closure DMO.

```
SELECT <Cases__dlm.ClosedDate__c> AS ClosedDate__c, SASearchInteractions__dlm.InteractionType__c AS InteractionType__c, APPROX_COUNT_DISTINCT(<Cases__dlm.CaseId__c>) AS CasesClosedWithInteraction__c, APPROX_COUNT_DISTINCT(<Cases__dlm.CaseId__c>)/MAX(SubQuery.TotalCasesClosed__c) * 100 AS PercentOfCasesClosed__c FROM <Cases__dlm> LEFT JOIN (SELECT <Cases__dlm.IsClosed__c> AS IsClosed__c, APPROX_COUNT_DISTINCT(<Cases__dlm.CaseId__c>) AS TotalCasesClosed__c FROM <Cases__dlm>  WHERE <Cases__dlm.IsClosed__c> = TRUE GROUP BY <Cases__dlm.IsClosed__c>) SubQuery on <Cases__dlm.IsClosed__c> = SubQuery.IsClosed__c LEFT JOIN SASearchResults__dlm ON <Cases__dlm.CaseId__c> = SASearchResults__dlm.RecordId__c LEFT JOIN SASearchInteractions__dlm ON SASearchResults__dlm.ResultId__c = SASearchInteractions__dlm.ResultId__c WHERE <Cases__dlm.IsClosed__c> = TRUE AND SASearchResults__dlm.RecordId__c IS NOT NULL AND SASearchInteractions__dlm.ResultId__c IS NOT NULL GROUP BY <Cases__dlm.ClosedDate__c>, SASearchInteractions__dlm.InteractionType__c
```

#### See Also

- [Create a Case Closure Calculated Insight](https://help.salesforce.com/s/articleView?id=ai.search_es_SA_case_closure_CI.htm&release=264.0.0&type=5 "Create a calculated insight (CI) with case-related metrics by using example SQL expressions. Use the CI to see how many interactions happen before the case is closed, to analyze case-related metrics, and to build dashboards.")