2014-10-10 53 views
0

我現在有一個select語句是這樣的:使用列作爲一個類別系列在BIRT

SELECT COUNT(CHECK_FORWARD.ID) AS CLOSED_SUMS 
FROM CHECK_FORWARD 
UNION ALL 
SELECT COUNT(CHECK_RETURN.ID) AS CLOSED_SUMS 
FROM CHECK_RETURN 
UNION ALL 
SELECT COUNT(CHECK_DEPOSIT.ID) AS CLOSED_SUMS 
FROM CHECK_DEPOSIT 

這將返回一個表像這樣

CLOSED_SUMS 
----------- 
1 
1 
21 

我試圖創建一個BIRT餅圖它顯示了這些資金的細目,但是如何去創造它卻不知所措。 BIRT想要一個類別系列(將這些款項分類)。

有什麼方法使用計算列創建列表創建一個表,如:

CLOSED_SUMS STATUS 
----------- ------ 
1    FORWARDED 
1    RETURNED 
21    DEPOSITED 

我一直沒能建立在計算列表達式嚮導的表達式返回一個柱所有三個字符串(即「轉發」,「返回」,「存儲」)。它只是重複其中一個字符串的所有值。

我應該使用一個數組來保存該值嗎?如果是的話,我該如何去做呢?

回答

1
SELECT COUNT(CHECK_FORWARD.ID) AS CLOSED_SUMS, 'FORWARDED' AS STATUS 
FROM CHECK_FORWARD 
UNION ALL 
SELECT COUNT(CHECK_RETURN.ID) AS CLOSED_SUMS, 'RETURNED' AS STATUS 
FROM CHECK_RETURN 
UNION ALL 
SELECT COUNT(CHECK_DEPOSIT.ID) AS CLOSED_SUMS, 'DEPOSITED' AS STATUS 
FROM CHECK_DEPOSIT 
+0

謝謝,我仍然掌握了sql。 – Raz 2014-10-10 18:37:25