0
嗨,我有一個出現在「未設置」兩次成爲拉動查詢:從列中選擇數據,其中空值和字符串不存在
現在一些檢查後,我知道這是因爲currentstage列具有NULLS和表中存儲的字符串'Not Set'。因此,下面會產生3個'Not set'字符串和195個NULLS被強制爲'Not Set'。 但是我真正想看到的是198 x'Not Sets'在我的#TempCircCount中。這怎麼能做到呢?
我的失敗代碼是在這裏:
IF OBJECT_ID('tempdb..#TempCircCount') is not null
DROP TABLE #TempCircCount
SELECT
ISNULL(cirRep.CurrentStage, 'Not Set') AS CurrentStage,
COUNT(ISNULL(cirRep.CurrentStage, 'Not Set')) AS Circuits
INTO #TempCircCount
FROM
[QuoteBase].[dbo].[CircuitReports] cirRep
RIGHT JOIN
Quotebase.dbo.Circuits cir ON cir.[PW Number] = CirRep.[PWNumber]
WHERE
Cir.Status='New Circuit Order'
GROUP BY CurrentStage
ORDER BY CurrentStage
SELECT
ISNULL(CurrentStage, 'Not Set') AS [CurrentStage],
Circuits AS Circuits
FROM #TempCircCount
GROUP BY CurrentStage, Circuits
ORDER BY CurrentStage
謝謝你的建議,表示感謝,解決方案解決了我的問題。 – MoiD101