문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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>

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top