将 Microsoft SQL SELECT CASE 移植到 Crystal Reports 11
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在问这个问题之前,我知道 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.
在 CR 中创建名为 CheckDate 的公式,其中包含以下内容:
并在报告中使用该公式。请注意,当您的报告设置了“将 NULL 值转换为默认值”选项时,您需要将第一行更改为类似的内容:
In CR create formula named CheckDate with following content:
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:
将您的“基本”查询构建为 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