0
我正在嘗試計算針對具有特定變量的服務器數量相同的子查詢計數的服務器數量。我可以返回一個實體的資產總數,但是當我返回符合條件的資產總數時,它會給我的總數而不是我具體業務的數量。SQL嵌套或相關查詢
SELECT DATEPART(week, GETDATE()) AS WEEK, bt.TranslatedParentBusiness AS [Parent Business], count(cars.ServerID) as [Count of Servers],
(Select count(auth.serverID) from AuthTracking auth where [AUTH STATUS] like 'PASSED')
FROM ASSETS.dbo._CARS AS cars INNER JOIN
ASSETS.dbo.BU_Translation AS bt ON cars.CARS_SubBusiness = bt.[CARS Sub Business]
GROUP BY bt.TranslatedParentBusiness
嘗試COUNT(*),而不是計數(cars.ServerID) – Sankara