【问题标题】:crystal reports two date parameters from two tables水晶报告两个表中的两个日期参数
【发布时间】:2013-03-15 03:37:15
【问题描述】:

我正在尝试根据两个表格制作生产报告,这两个表格的日期不同。 (下面的表格示例)

first table (machine ID, production time, date)
-result should be sum of time group by machine ID (parameters - date from - to)

second table (machine ID, repair time, date)
-result should be sum of repair time group by(parameters - date from-to).

在报告中,我需要计算两个表中的总和(例如:from 1.1.2013 to 10.1.2013)。问题是我需要从两个表中使用两个不同的日期参数,但是当我使用该连接时,该连接不能像LEFT OUTER JOIN 那样工作,而是INNER JOIN。(从第一个表我需要所有记录,从第二个只有id=id

表格示例:

结果必须是:

机器ID |生产时间总和 |维修时间总和(如果有) - 基于从到到

【问题讨论】:

  • 请发布您的记录选择公式和您正在使用的表格连接。
  • 表连接:table1 LEFT OUTER JOIN table2 on machineID=machineID 选择标准:{spent time} in {?date_from} to {?date_to} and {repair time} in {?date_from} to {?date_to}

标签: crystal-reports report


【解决方案1】:

不要加入表,而是尝试联合它们。类似于以下内容:

SELECT machineID, spent_time as time, production_date as date, 'Production' as type
FROM table1
WHERE production_date between {?date_from} and {?date_to}

UNION

SELECT machineID, repair_time as time, repair_date as date, 'Repair' as type
FROM table2
WHERE repair_date between {?date_from} and {?date_to}

然后您可以轻松地按机器分组并分别汇总所有“生产”行和所有“修复”行。

【讨论】:

  • 谢谢,水晶报表中是这样的吗?
  • @user2171131 您可以在数据库中创建视图或在 Crystal 中创建 SQL 命令。无论哪种方式都有效。
【解决方案2】:

您可以在一个“主”报告中嵌入两个子报告。在主报表中定义参数,然后将它们链接到每个子报表。

【讨论】:

    猜你喜欢
    • 2010-12-25
    • 1970-01-01
    • 1970-01-01
    • 2016-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多