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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Case in a crystal reports command parameter.

Status
Not open for further replies.

mohebkasem

IS-IT--Management
Mar 7, 2013
1
0
0
US
Hi All,
I am building a report with a sql server command script. I am trying to set up a report the user has the flexibility to run it with two options. The report keeps giving me a syntax error.

Ultimately what I'd like to write is something in this effect.

SELECT
Field_1
Field_2
FROM Table_A
WHERE
CASE WHEN {?Parmater1 = 'All' THEN
Field_4 in (Select id form Table_B)
ELSE Field Field_5 = {?Parmater2}
END

Your help is much appreciated.
Thank you
 
Text parameters have to be in single quotes (I have no idea why). I correct the query to what I think should work. I have not done a query like this before. I would normally do some testing in another product (TOAD, SSMS, etc.)
SELECT
Field_1
Field_2
FROM Table_A
WHERE
CASE WHEN '{?Parmater1}' = 'All' THEN
Field_4 in (Select id from Table_B)
ELSE Field Field_5 = '{?Parmater2}'
END
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top