根据组中的一条记录选择一组记录
我似乎被一个问题困住了。我使用 Crystal Reports 2008 从 MS-SQL 数据库中提取记录列表。涉及两个表(它们包含订户的订单数据)。第一个表是 OrderMst,第二个表是 OrderDtl。它们由两个字段连接:帐户和子编号。每个帐户有许多子编号,每个子编号有许多发票编号。每个发票行都有一个列,告诉我它是否是最新的发票。我需要查看此记录以确定客户是否处于活动状态、已取消或已过期。然后,根据其状态,我需要选择该子编号的所有发票。我一直在试图找出一种方法来做到这一点。
下面是一个示例:
OrderMst:
Account SubNumber Pub
72781651 0025 NAVL
72781651 0012 RYIR
72781651 0001 RHCS
80156287 0015 VGFA
80156287 0012 NAVL
OrderDtl:
Account SubNumber InvoiceNumber PubStatus RenewalThere
72781651 0025 15894578 A 0
72781651 0025 15754897 R 1
72781651 0025 15753412 R 1
72781651 0012 15753357 C 0
72781651 0012 15749875 R 1
72781651 0001 15465874 X 0
72781651 0001 15425789 R 1
80156287 0015 15656738 A 0
80156287 0012 15387956 C 0
80156287 0012 15324568 R 1
因此,如果我要查找有效订阅的所有发票计数,我会选择 {OrderDtl.RenewalThere} = 0
,我的报告结果将显示 Account 72781651 子编号 0025 有 3 张发票,帐户 80156287 子编号 0015 有 1 张发票。这就是我被困住的地方。我需要使用一个发票级别记录来告诉我想要哪个订阅,然后获取该发票的所有发票级别记录。有什么想法吗?
I seem to be very stuck on a problem. I using Crystal Reports 2008 to pull a list of records from a MS-SQL database. There are two tables involved (they contain order data for subscribers). The first table is OrderMst and the second is OrderDtl. They are joined by two fields, Account and SubNumber. Each Account has many SubNumbers and each SubNumber has many InvoiceNumbers. Each invoice row has a column that tells me wether or not it's the most recent invoice. I need to look at this record to determine whether a customer is active, cancelled, or expired. Then, depending on their status I need to select all the invoices for that SubNumber. I'm stuck trying to figure out a way to do that.
Here's an example:
OrderMst:
Account SubNumber Pub
72781651 0025 NAVL
72781651 0012 RYIR
72781651 0001 RHCS
80156287 0015 VGFA
80156287 0012 NAVL
OrderDtl:
Account SubNumber InvoiceNumber PubStatus RenewalThere
72781651 0025 15894578 A 0
72781651 0025 15754897 R 1
72781651 0025 15753412 R 1
72781651 0012 15753357 C 0
72781651 0012 15749875 R 1
72781651 0001 15465874 X 0
72781651 0001 15425789 R 1
80156287 0015 15656738 A 0
80156287 0012 15387956 C 0
80156287 0012 15324568 R 1
So, if I were looking for a count of all the invoices for active subscriptions, I would select {OrderDtl.RenewalThere} = 0
, and my report results would show Account 72781651 SubNumber 0025 has 3 invoices and Account 80156287 SubNumber 0015 has 1 invoice. This is where I'm stuck. I need to use one invoice level record to tell me which subscription I want, and then grab all invoice level records for that invoice. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你想要的是半连接:
HTH
What you want is a semi-join:
HTH