Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

How to write the following sql query int o work flow

$
0
0

 Hello Everyone

                      I want to get all user and their active cases, and then find which user have less number of cases

i have write the following sql query , i want to implement that in work, how can i write using query expression or how can i use it ?

SELECT TOP(1) a.SystemUserId, a.FullName, MIN(a.[Total]) AS total FROM (
SELECT us.SystemUserId,us.fullname,
COUNT(*) AS [Total]
FROM SystemUserBase AS us
LEFT JOIN IncidentBase AS ca
ON us.SystemUserId = ca.OwnerID
WHERE
StateCode=0
GROUP BY us.Fullname,SystemUserId
HAVING SystemUserId in (SELECT SystemUserId FROM TeamMembership WHERE TeamId = 'd6ae0aab-d60a-e711-9401-0050569b1ee7')
)a
GROUP BY a.FullName,a.Total,a.SystemUserId
ORDER BY total ascending



Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>