Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports 2013 -sql expression

Status
Not open for further replies.

patsylipp

Technical User
May 11, 2017
2
US
I have never used sql expression in crystal here is my code
(SELECT SUM(LABOR_HOURS) FROM WO_TASK WHERE WO_TASK.WOO_AUTO_KEY=WO_OPERATION.WOO_AUTO_KEY and not(WO_TASK.SYSUR_AUTO_KEY in [125,126,127,129,130,132,131,249]))

I am getting a missing expression error when I try and save it.
PS this is not my report someone else wrote it and I am just trying to fix this one thing.
Thanks

Patsy
 
Not sure if it matters (never used SQl expressions myself). But the syntax for the IN statement varies depending on the database (MS-SQL wants parenthesis around the value list not brackets). That is the only idea I have.
 
I did remove the [] did not seem to make a difference. I resolved this by getting rid of sql expressions and using a command instead.

Thanks
 
Hi Patsy,

I see two issues.
RE: (SELECT SUM(LABOR_HOURS) FROM WO_TASK WHERE WO_TASK.WOO_AUTO_KEY=WO_OPERATION.WOO_AUTO_KEY and not(WO_TASK.SYSUR_AUTO_KEY in [125,126,127,129,130,132,131,249]))

You should assign your sum a column name otherwise it will be automatically generated and probably messy in CR:
SUM(LABOR_HOURS) AS LABOR_SUM

Arrays should be collected with round brackets:

in (125,126,127,129,130,132,131,249)

So try this:

(
SELECT
SUM(LABOR_HOURS) AS LABOR_SUM
FROM WO_TASK
WHERE WO_TASK.WOO_AUTO_KEY=WO_OPERATION.WOO_AUTO_KEY and
not( WO_TASK.SYSUR_AUTO_KEY in (125,126,127,129,130,132,131,249) )
);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top