Count Distinct

2
I need to be able to count the number of distinct objects there are in the database based on a certain attribute. I was thinking that in MS SQL you can usually do SELECT COUNT(DISTINCT column_name) FROM table_name. Can you do this in OQL? I need to then store this attribute into an object. So will probably need to do the OQL in a java action and pass back the number. Could someone advice me on this? Also if there is a better way to do it in a Microflow, then let me know. Thanks
asked
2 answers
0

The following code parses correctly. I assume it will work:

FROM SLM.Service
SELECT COUNT( DISTINCT(ServiceName) ) AS DistinctServices
answered
-2

You could use a list operation for it. Retrieve all the objects so you have a list and then do a list operation (union) on itself. You then have the same list but now distinct. You can then count the list (another list operation) to have the number of distinct objects.

answered