I have a row in a table that looks like this
Time TenantID CallingService PolicyList PolicyInstanceList
2019-11-23 07:30:30.0000000 ######## S1 p1, p2 pi1,pi2,pi3,pi4
2019-11-23 07:30:31.0000000 ######## S1 p1, p2 pi1,pi2,pi3,pi4
2019-11-23 07:30:32.0000000 ######## S1 p1, p2 pi1,pi2,pi3,pi4
2019-11-23 07:30:33.0000000 ######## S1 p1, p2 pi1,pi2,pi3,pi4
2019-11-23 07:30:34.0000000 ######## S1 p1, p2 pi1,pi2,pi3,pi4
2019-11-23 07:30:35.0000000 ######## S1 p1, p2 pi1,pi2,pi3,pi4
2019-11-23 07:30:36.0000000 ######## S1 p1, p2 pi1,pi2,pi3,pi4
2019-11-23 07:30:37.0000000 ######## S1 p1, p2 pi1,pi2,pi3,pi4
2019-11-23 07:30:38.0000000 ######## S1 p1, p2 pi1,pi2,pi3,pi4
I have aggregated it based on the TenantID so that it looks like this
Time TADCount TenantID
2019-11-23 00:00:00.0000 8 ########
However, I need to add more granularity to my aggregation so I can do it based on multiple keys. For example,
Time TADCount TenantID CallingService PolicyList PolicyInstanceList
2019-11-23 00:00:00.0000 1 ######## S1 p2 pi3
Here is the aggregation statement I have been using for reference to achieve the 2nd code block.
SELECT DATEADD(DAY, DATEDIFF(DAY, 0, [Time]), 0) AS Time
,Count([TenantId]) AS TADCount, [TenantId]
--,Count([PolicyList]) AS PolicyListCount, [PolicyList]
FROM [dbo].[acms_data]
GROUP by DATEADD(DAY, DATEDIFF(DAY, 0, [Time]), 0),[TenantId]