Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Convert Crystal Report Expression

Author  Topic 

tupacmoche
Starting Member

7 Posts

Posted - 2013-11-17 : 22:46:19
I'm converting a Crystal Report into SQL code and need help/direction on how to implement expressions created in the reporting tool in sql code. Below is an expression that returns 1, 2, or 3 depending on how it is evaluated by the run time program. Any assistance in converting this expression into SQL code is appreciated.

Code starts here ***************

if IsNull({WorkAssignment.StartDateTime}) or IsNull({WorkSet.ScheduledReadDate}) then
(
3
)

else
(
if (Date({WorkAssignment.StartDateTime}) <= Date({WorkSet.ScheduledReadDate}) and
({WorkAssignment.WorkFilterName} <> 'DNRs' and {WorkAssignment.WorkFilterName} <> 'Type 2s/3s')) or
(val(right({WorkSet.WorkSetID}, 2)) < 50 and mid({WorkSet.WorkSetID}, len({WorkSet.WorkSetID}) - 3, 1) = "0") then
1

else if (Date({WorkAssignment.StartDateTime}) <= Date({WorkSet.ScheduledReadDate}) and
({WorkAssignment.WorkFilterName} = 'DNRs' or {WorkAssignment.WorkFilterName} = 'Type 2s/3s')) or

((val(right({WorkSet.WorkSetID}, 2)) >= 50 and val(right({WorkSet.WorkSetID}, 2)) <= 69) and
mid({WorkSet.WorkSetID}, len({WorkSet.WorkSetID}) - 3, 1) = "0") then
2
else
3
;
)
;

Code ends here *******************************

The expression is used to group records based on how it is evaluated. Record that belong to group 1 are put into group 1, record that are evaluated as 2 into group two and so on.
   

- Advertisement -