gpt4 book ai didi

c# - Crystal 报表 : Place row data from grouped records into columns

转载 作者:太空宇宙 更新时间:2023-11-03 22:07:16 25 4
gpt4 key购买 nike

好的,所以我的 Crystal Reports 数据源有如下所示的行:

|--------+----------+---------+------------+-----------+-----------+---------|
| SiteNo | SiteName | SiteMgr | ContType | ContName | ContState | ContZip |
|--------+----------+---------+------------+-----------+-----------+---------|
| 1262 | S. Belt | Joe B. | Landlord | Mike | CA | 90017 |
| 1262 | S. Belt | Joe B. | Architect | Paul | TX | 77040 |
| 1262 | S. Belt | Joe B. | Contractor | Chris | AZ | 85016 |
|--------+----------+---------+------------+-----------+-----------+---------|

有数百个站点编号(SiteNo),每个站点编号有三行......报告中的每条记录需要这样格式化:

|------------+------------+------------+------------|
| Site | Landlord | Architect | Contractor |
|------------+------------+------------+------------|
| 1262 | Mike | Paul | Chris |
| S. Belt | CA | TX | AZ |
| Joe B. | 90017 | 77040 | 85016 |
|------------+------------+------------+------------|

由于数据源的前三列(SiteNo、SiteName、SiteMgr)对于特定站点始终相同,因此报告按 SiteNo 分组。我已经弄清楚了这部分。我把它放在组页脚中。然后,我遇到的问题是,根据联系人类型(ContType:房东、建筑师或承包商),信息需要放在相关的列中。

不确定执行此操作的最佳方法?任何帮助将不胜感激。

最佳答案

您可以通过使用 Crystal 公式来实现这一点,但我认为如果您像这样修改 SQL 查询,它会更容易理解和维护:

select SiteNo,
max(SiteName) SiteName,
max(SiteMgr) SiteMgr,
max(case ContType
when 'Landlord' then ContName
else NULL
end) LandlordContName,
max(case ContType
when 'Landlord' then ContState
else NULL
end) LandlordContState,
max(case ContType
when 'Landlord' then ContZip
else NULL
end) LandlordContZip,
max(case ContType
when 'Architect' then ContName
else NULL
end) ArchitectContName,
max(case ContType
when 'Architect' then ContState
else NULL
end) ArchitectContState,
max(case ContType
when 'Architect' then ContZip
else NULL
end) ArchitectContZip,
max(case ContType
when 'Contractor' then ContName
else NULL
end) ContractorContName,
max(case ContType
when 'Contractor' then ContState
else NULL
end) ContractorContState,
max(case ContType
when 'Contractor' then ContZip
else NULL
end) ContractorContZip
from Contacts
group by SiteNo

加长报告的详细信息部分,使其可以包含三行,然后放置:

  • SiteNo、LandlordContName、ArchitectContName 和 ContractorContName 在第一行;
  • 第二行的 SiteName、LandlordContState、ArchitectContState 和 ContractorContState;
  • 第三行的 SiteMgr、LandlordContZip、ArchitectContZip 和 ContractorContZip。

关于c# - Crystal 报表 : Place row data from grouped records into columns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7974724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com