在 SQL Server 中,我编写了一个查询来计算特定列,但我在多个表中显示所有计数,这不是一个好的显示方式。如何在新表中单行显示所有表?
select COUNT(s.AssetSubType) as 'PhysicalServers' from Asset s
where s.CompanyId = @companyId and
s.AssetType = 1 and
s.AssetSubType = 4
select COUNT(s.AssetSubType) as 'WorkStations' from Asset s
where s.CompanyId = @companyId and
s.AssetType = 1 and
s.AssetSubType = 1 or s.AssetSubType = 3
select COUNT(s.AssetSubType) as 'EmailOnlyUsers' from Asset s
where s.CompanyId = @companyId and
s.AssetType = 2 and
s.AssetSubType = 16
select COUNT(s.OperatingSystem) as '#OfMSServers' from Asset s
where s.CompanyId = @companyId and
s.AssetType = 1 and
s.AssetSubType = 4 and
s.OperatingSystem = 1
select COUNT(s.OperatingSystem) as '#OfLinuxServers' from Asset s
where s.CompanyId = @companyId and
s.AssetType = 1 and
s.AssetSubType = 4 and
s.OperatingSystem = 2