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