How to get distinct records from a database view?

santhoshi6
Kilo Contributor

Hi,

I need to take the sum of resolve time (calendar_stc) in an automated indicator from the distinct incidents achieved from the database view which is the join of incident and task_ci tables where incident_sys_id=task_ci_task. There is a column in task_ci called tier type(dot-walked from cmdb_ci) which stores the CI information whether it belongs to tier 1 or tier 2 or tier 3. I am getting duplicate incidents since there are multiple CI's belonging to Tier 1, 2 and 3. Can anyone help me how to get distinct incident records for achieving the sum of resolve time for my automated indicator.

2 REPLIES 2

Jochen Pohle
ServiceNow Employee
ServiceNow Employee

Hi,



on the Automated Indicator form you could use "Count Distinct" in the "Aggregate" field.



CountDistinct.png



If that does not help you might consider creating 3 Automated Indicators - one for each tier - and create a Formula Indicator to calculate the overall sum.



Greets,


Jochen


Hi Jochen,



I need to do   sum of resolve time   of those distinct incidents. We cannot apply both Sum of Resolve Time and Count Distinct on incident sys_id at a time on the automated indicator. So can we get distinct incidents from the database view itself. And in scripts glide records are not accepted. It is throwing an error.