BIRT 饼图、级联参数和 SQL 格式

BIRT Pie Chart, Cascading Parameters, & SQL Formatting

我有一个显示基于以下查询的饼图的报告:

SELECT 
    COUNT(COURTESY_CHECK.CHECK_NUMBER) AS SUM, 
    'FORWARDED' AS STATUS
FROM
    COURTESY_CHECK
    INNER JOIN CHECK_FORWARD 
    ON COURTESY_CHECK.ID = CHECK_FORWARD.COURTESY_CHECK_ID
WHERE 
    to_char(COURTESY_CHECK.DATE_RECEIVED, 'FMMonth') = ? AND 
    EXTRACT (YEAR FROM COURTESY_CHECK.DATE_RECEIVED) = ?


UNION ALL

SELECT 
    COUNT(COURTESY_CHECK.CHECK_NUMBER) AS SUM, 
    'RETURNED' AS STATUS
FROM 
    COURTESY_CHECK
    INNER JOIN CHECK_RETURN 
    ON COURTESY_CHECK.ID = CHECK_RETURN.COURTESY_CHECK_ID
WHERE 
    to_char(COURTESY_CHECK.DATE_RECEIVED, 'FMMonth') = ? AND 
    EXTRACT (YEAR FROM COURTESY_CHECK.DATE_RECEIVED) = ?

UNION ALL 

SELECT  
    COUNT(COURTESY_CHECK.CHECK_NUMBER) AS SUM,
    'IPAC' AS STATUS 
FROM 
    COURTESY_CHECK
    INNER JOIN CHECK_DEPOSIT 
        ON COURTESY_CHECK.ID = CHECK_DEPOSIT.COURTESY_CHECK_ID
WHERE 
    COURTESY_CHECK.CHECK_STATUS = 'CLOSED' AND
    to_char(COURTESY_CHECK.DATE_RECEIVED, 'FMMonth') = ? AND 
    EXTRACT (YEAR FROM COURTESY_CHECK.DATE_RECEIVED) = ?

UNION ALL

SELECT 
    COUNT(COURTESY_CHECK.CHECK_NUMBER) AS SUM, 
    'PENDING' AS STATUS
FROM 
    COURTESY_CHECK
WHERE 
    COURTESY_CHECK.CHECK_STATUS = 'PENDING' AND
    to_char(COURTESY_CHECK.DATE_RECEIVED, 'FMMonth') = ? AND 
    EXTRACT (YEAR FROM COURTESY_CHECK.DATE_RECEIVED) = ?

UNION ALL 

SELECT 
    COUNT(COURTESY_CHECK.CHECK_NUMBER) AS SUM, 
    'DEPOSITED' AS STATUS
FROM 
    COURTESY_CHECK
WHERE 
    COURTESY_CHECK.CHECK_STATUS = 'DEPOSITED' AND
    to_char(COURTESY_CHECK.DATE_RECEIVED, 'FMMonth') = ? AND 
    EXTRACT (YEAR FROM COURTESY_CHECK.DATE_RECEIVED) = ?

我的问题是这部分:

WHERE 
    to_char(COURTESY_CHECK.DATE_RECEIVED, 'FMMonth') = ? AND 
    EXTRACT (YEAR FROM COURTESY_CHECK.DATE_RECEIVED) = ?

月份和年份参数基于从以下查询动态创建的级联参数:

SELECT  

 DISTINCT to_char(COURTESY_CHECK.DATE_CREATED, 'Month') AS MN, 
 EXTRACT (YEAR FROM COURTESY_CHECK.DATE_CREATED) AS YR 

FROM COURTESY_CHECK

我发现使用 'Month' 会提取月份名称并尾随 spaces,而 'FMMonth' 会截断月份名称并删除 spaces .

我试过对两个查询都使用 'Month' 并在应该是饼图的地方看到一个空的白色 space。对这两个查询使用 'FMMonth' 根本不会给我饼图(空的或其他)。对一个或另一个使用 'FMMonth' 也不起作用。

我正在使用 to_char,因为这就是我在级联参数下拉菜单中显示月份名称的方式。我希望报告的用户看到月份名称而不是月份编号。

我不知道为什么饼图没有出现。

您应该在级联参数和查询中使用月份编号,并利用 "displayText" 属性 在下拉菜单中显示月份名称。这将解决由于字符转换引起的任何类型的问题,请参见下面摘自 this example 的屏幕截图。在您的情况下,级联参数的查询应更改为同时显示月份 ID 和名称:

SELECT  
 EXTRACT (MONTH FROM COURTESY_CHECK.DATE_CREATED) MN_ID,
 DISTINCT to_char(COURTESY_CHECK.DATE_CREATED, 'Month') AS MN_NAME, 
 EXTRACT (YEAR FROM COURTESY_CHECK.DATE_CREATED) AS YR 
FROM COURTESY_CHECK

在下面的示例中,部门级别显示为DEPARTMENT_NAME,但它实际上使用了DEPARTMENT_ID作为参数值,它是一个整数。您可以使用这些表达式(假设您将其命名为 "month")来处理报表正文中月份参数的值和显示文本:

params["month"].value;
params["month"].displayText;