LINQ怎么写多表分组统计 200
selectKeyDBas服务器名,(selectcount(KeyDB)fromCompanyTotalwhereCompanyTotal.KeyDB=t.KeyDBa...
select
KeyDB as 服务器名,
(select count(KeyDB) from CompanyTotal where CompanyTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' and (CompanyType != 'CarSynthesizeMonitor'and CompanyType != 'Service')) as '运输',
(select count(KeyDB) from CompanyTotal where CompanyTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' and (CompanyType = 'CarSynthesizeMonitor' or CompanyType = 'Service')) as '维修',
(select count(KeyDB) from UserTotal where UserTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' ) as '车辆',
(select count(KeyDB) from VehicleTotal where VehicleTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' ) as '人员'
from
(
select KeyDB from CompanyTotal group by KeyDB
union
select KeyDB from CompanyTotal group by KeyDB
union
select KeyDB from UserTotal group by KeyDB
union
select KeyDB from VehicleTotal group by KeyDB
) as t
该怎么改成LINQ??? 展开
KeyDB as 服务器名,
(select count(KeyDB) from CompanyTotal where CompanyTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' and (CompanyType != 'CarSynthesizeMonitor'and CompanyType != 'Service')) as '运输',
(select count(KeyDB) from CompanyTotal where CompanyTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' and (CompanyType = 'CarSynthesizeMonitor' or CompanyType = 'Service')) as '维修',
(select count(KeyDB) from UserTotal where UserTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' ) as '车辆',
(select count(KeyDB) from VehicleTotal where VehicleTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' ) as '人员'
from
(
select KeyDB from CompanyTotal group by KeyDB
union
select KeyDB from CompanyTotal group by KeyDB
union
select KeyDB from UserTotal group by KeyDB
union
select KeyDB from VehicleTotal group by KeyDB
) as t
该怎么改成LINQ??? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询