2010-06-30 55 views
0

我有一個查詢的訪問就是這種擺脫零:得到在訪問查詢的輸出

SELECT iif([Cup Type] like '*Cylinder*',count([Cup Type]),0) AS Cylinder, 
iif([Cup Type] like '*Snap*',count([Cup Type]),0) AS Snap, 
iif([Cup Type] like '*Tip*',count([Cup Type]),0) AS Tip, 
iif([Cup Type] like '*Other*',count([Cup Type]),0) AS Other 
FROM [Lab Occurrence Form] 
WHERE [1 0 Preanalytical (Before Testing)] Like '*1.3 QNS-Quantity Not Sufficient*' 
And ((([Lab Occurrence Form].[Occurrence Date]) 
Between Forms!Meeting_Reasons_Frequency!Text4 
And Forms!Meeting_Reasons_Frequency!Text2)) 
GROUP BY [Cup Type]; 

輸出看起來是這樣的:

Cylinder Snap Tip Other 
0 0 0 0 
71 0 0 0 
0 0 0 18 
0 7 0 0 
0 0 4 0 

我的可怕格式道歉,但我如何擺脫零?

,我應該這樣做select cylinder, snap, tip, other, from query1 where cylinder <> 0 etc..???

我所要的輸出是:

Cylinder Snap Tip Other 
71 7 4 18 
+0

你的意思是「擺脫零」?你能顯示你想要的輸出嗎? – 2010-06-30 23:06:52

+0

是的,我剛剛編輯它,感謝您的幫助 – 2010-06-30 23:07:12

回答

2

你澄清後,你會想什麼,是切換計數()和IIF(順序),並改變它總結(),讓你得到

sum(iif([Cup Type] like '*Cylinder*', 1, 0))

,然後刪除group by以僅獲得一個結果行。

+0

非常感謝!!!!!!! – 2010-07-01 15:19:36

1

你的意思是你想獲得的所有零擺脫了行? 然後,你將不得不添加類似

AND ([Cup Type] like '*Cylinder*' or [Cup Type] like '*Snap*' or [Cup Type] like '*Tip*' or [Cup Type] like '*Other*') 

到你的where條件。

+0

對不起,這是不正確的 – 2010-06-30 23:11:23

1

目前還不清楚你將要分組的內容,但是你可以在每個字段上使用Max()。

但我懷疑這個問題比你的解釋建議更復雜。