使用子报表抑制 Crystal Reports 中的部分

发布于 2024-07-30 06:34:03 字数 1011 浏览 4 评论 0原文

我正在尝试根据此 sql 查询

SELECT *
在 crystal reports 11 中创建一个报告     FROM(表)OM、(表)OL、(表)C
    其中 OM.ORDER = OL.ORDER
    并且 OM.COMPANY = C.COMPANY
    AND(存在(选择 *
          FROM(表)OSD,(表)OSDD
         其中 OSD.ORDER = OL.ORDER
         AND OSD.LINE = OL.LINE
         并且 OSD.REVISION = OL.REVISION
         并且 OSD.DIM = OSDD.DIM
           AND OSDD.SHAPE = OL.SHAPE))

我认为最好的开始方法是创建主报告使用前两个表并使用查询的“EXISTS”部分创建子报告并链接回主报告。

我的详细信息部分包含主报表和子报表中的数据。 我得到了子报表返回值的正确结果,但如果子报表为空,我希望能够抑制主报表的详细信息部分,但我找不到在任何位置引用子报表的方法选择公式。

如果有更好的方法来模拟这个查询,我愿意接受建议。

I am trying to create a report in crystal reports 11 based on this sql query

SELECT *
    FROM (table) OM, (table) OL, (table) C
    WHERE OM.ORDER = OL.ORDER
    AND OM.COMPANY = C.COMPANY
    AND (EXISTS (SELECT *
            FROM (table) OSD, (table) OSDD
            WHERE OSD.ORDER = OL.ORDER
           
AND OSD.LINE = OL.LINE
            AND OSD.REVISION = OL.REVISION
            AND OSD.DIM = OSDD.DIM
            AND OSDD.SHAPE = OL.SHAPE))

I thought the best way to start was by creating the main report using the first two tables and creating a subreport using the "EXISTS" section of the query and linking back to the main report.

My details section contains both data from the main report and the subreport. I get the correct results back for where the subreport returns a value, but I want to be able to suppress the detail section of the main report if the subreport is null, but I can't find a way to reference the subreport in any of the selection formulas.

I am open to suggestions if there is a better way to mimic this query as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

听闻余生 2024-08-06 06:34:03

如果您不想看到子报表为空的任何数据,则没有理由使用子报表。 你使报告过于复杂化了。

如果您仍想这样做,Suppress 属性允许使用表达式。 您可能必须使用全局变量,根据子报表设置变量,但我怀疑它会在显示行之前设置。

There's no reason to use a subreport if you don't want to see any data where the subreport is null. You're overcomplicating the report.

If you still want to do this, the Suppress attribute allows expressions. You would likely have to use a globalvar variable, set the variable based on the subreport but I doubt it would be set prior to the row being displayed.

若水微香 2024-08-06 06:34:03

我不确定您使用的是什么类型的数据库,但我相信您可能可以使用类似的东西:

select * --you probably should narrow this down instead of using a *
from (table) OM
inner join (table) OL on OM.ORDER = OL.ORDER
inner join (table) C on OM.COMPANY = C.COMPANY
inner join (table) OSD on OSD.ORDER = OL.ORDER 
    and OSD.LINE = OL.LINE 
    and OSD.REVISION = OL.REVISION
    and OSD.DIM = OSDD.DIM
inner join (table) OSDD on OSDD.SHAPE = OL.SHAPE

这是我的想法,未经测试,但想法是它会显示来自的所有记录找到匹配项的 OM、OL、C、OSD 和 OSDD。 由于您没有在 OSD 或 OSDD 上使用左连接,因此不应有任何空行。

但是,您始终可以将它们更改为左外连接,例如:

select * --you probably should narrow this down instead of using a *
from (table) OM
inner join (table) OL on OM.ORDER = OL.ORDER
inner join (table) C on OM.COMPANY = C.COMPANY
left outer join (table) OSD on OSD.ORDER = OL.ORDER 
    and OSD.LINE = OL.LINE 
    and OSD.REVISION = OL.REVISION
    and OSD.DIM = OSDD.DIM
left outer join (table) OSDD on OSDD.SHAPE = OL.SHAPE

这将为您提供 OM、OL 和 C 中的所有行,以及 OSD 和 OSDD 中找到匹配项的行。 然后,您有许多选项可以抑制您不希望看到的行,例如按照 rexem 建议使用专家部分中的抑制公式。

希望这可以帮助。

I'm not sure if what type of database you are using, but I believe that you probably can use something like:

select * --you probably should narrow this down instead of using a *
from (table) OM
inner join (table) OL on OM.ORDER = OL.ORDER
inner join (table) C on OM.COMPANY = C.COMPANY
inner join (table) OSD on OSD.ORDER = OL.ORDER 
    and OSD.LINE = OL.LINE 
    and OSD.REVISION = OL.REVISION
    and OSD.DIM = OSDD.DIM
inner join (table) OSDD on OSDD.SHAPE = OL.SHAPE

This is off the top of my head and not tested, but the idea is that it would show all of the records from OM, OL, C, OSD, and OSDD where it found matches. since you are not using a left join on OSD or OSDD you should not have any null rows.

However you could always change those to left outer joins like:

select * --you probably should narrow this down instead of using a *
from (table) OM
inner join (table) OL on OM.ORDER = OL.ORDER
inner join (table) C on OM.COMPANY = C.COMPANY
left outer join (table) OSD on OSD.ORDER = OL.ORDER 
    and OSD.LINE = OL.LINE 
    and OSD.REVISION = OL.REVISION
    and OSD.DIM = OSDD.DIM
left outer join (table) OSDD on OSDD.SHAPE = OL.SHAPE

This would give you all rows from OM, OL, and C and only the rows from OSD and OSDD where it found a match. Then you have a number of options to suppress the rows you do not wish to see such as using the he suppress formula in the section expert as rexem suggested.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文