将 Microsoft SQL SELECT CASE 移植到 Crystal Reports 11

发布于 2024-10-04 02:16:50 字数 280 浏览 2 评论 0原文

我有一个 Microsoft SQL 查询:

SELECT case 
          when ReHired Is Null Then HireDate 
          else ReHired 
       end CheckDate
 FROM   
       Employees

这当然会使用 HireDate 或 Re-HiredDate 创建一个列 — CheckDate。

如何将相同的功能移植到 Crystal Reports?

I have a Microsoft SQL Query:

SELECT case 
          when ReHired Is Null Then HireDate 
          else ReHired 
       end CheckDate
 FROM   
       Employees

This of course creates a column -- CheckDate -- using either the HireDate or Re-HiredDate.

How can I port this same functionality to Crystal Reports?

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

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

发布评论

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

评论(3

最单纯的乌龟 2024-10-11 02:16:50

在问这个问题之前,我知道 CR 中的 SQL 表达式字段看起来和听起来都像我想要的,但我尝试了一些方法,但无法让它工作。

然而,最后,我设法.. 只需创建一个 SQL 表达式字段,插入选择表达式 -- CASE WHEN ReHired IS NULL THEN HireDate ELSE ReHired END CheckDate --。

然后,只需在 CR 公式和表达式中将其引用为 {%CheckDate} 即可。非常简单,非常强大,正是我想要的。

希望这对将来的其他人有帮助。

I knew before asking this that SQL Expression Fields in CR looked like and sounded like what I wanted, but I tried a few things and couldn't get it to work.

Finally, however, I managed to.. Just create a SQL Expression Field, plug in the select expression -- CASE WHEN ReHired IS NULL THEN HireDate ELSE ReHired END CheckDate --.

Then, simply reference this as {%CheckDate} within your CR formulas and expressions. Very easy, very powerful, exactly what I wanted.

Hope this helps someone else in the future.

沫尐诺 2024-10-11 02:16:50

在 CR 中创建名为 CheckDate 的公式,其中包含以下内容:

if isnull({Employees.ReHired})
then {Employees.HireDate}
else {Employees.ReHired}

并在报告中使用该公式。请注意,当您的报告设置了“将 NULL 值转换为默认值”选项时,您需要将第一行更改为类似的内容:

if {Employees.ReHired}=<your db default value for ReHired column>

In CR create formula named CheckDate with following content:

if isnull({Employees.ReHired})
then {Employees.HireDate}
else {Employees.ReHired}

and use that formula in report. Note that when your report has "Convert NULL values to default" option set, you need to change first line to someting similar:

if {Employees.ReHired}=<your db default value for ReHired column>
南汐寒笙箫 2024-10-11 02:16:50

将您的“基本”查询构建为 sql server 上的视图,然后允许 crystal 对其进行过滤,或者作为返回 sql server 上的参数化存储过程或函数的表,并让 crystal 传递参数。在这两种情况下,都在结果集中包含“计算”字段

frame your "base" query as either a view on the sql server, and then allow crystal to filter it, or as a table returning parameterized stored procedure or function on the sql server and have crystal pass the parameters. In both cases including your "calculated" field in the result set

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