I am using LinqJs and trying to create a grouped set with a particular set of data. I have written the query in MS-SQL and would like some help to convert it into LinqJs. My main problem is trying to get the distinct count. This is my SQL query with a sample table and data.
declare @table TABLE(appID int,appName varchar(50), dcID varchar(20), projectID varchar(10))
INSERT INTO @table
values ('160146','TAP','GFTS2018123','P1'),('160146','TAP','GFTS2018123','P2')
select appID, appName, dcID, count(distinct(dcID)) as DcCount, count(distinct(projectID)) as ProjectCount
from @table
group by appID, appName, dcID
This is my incomplete LinqJs query
var statusData = Enumerable.From(data).GroupBy(
null,
null,
"{ AppID: $.AppID, AppName: $.AppName, dcID: $.dcID,DcCount: $$.Count('$.dcID'), projectCount:$$.Count('$.projectID') }",
"$.AppID"
).ToArray();
The output i expect is as
appID appName dcID DcCount ProjectCount
160146 TAP GFTS2018123 1 2