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

Select Case Statement

Status
Not open for further replies.

dianemarie

Instructor
Jul 11, 2001
583
US
Hello, I have two parameters. First one (@ByOwnLst) has two options "owner" and "list". The second parameter (@OwnLst) runs the report by owner or list number, depending on the choice selected in the @ByOwnLst parameter. In my Where statment I have the following, which returns the error: incorrect syntax near the word 'IN'. I've tried it several different ways. Any help would be greatly appreciated. Thank you.

Where
Case
When @ByOwnLst = 'Owner' then lo.owner in (@OwnLst)
Else lo.lnum in (@OwnLst)
End

 
Try this:

Code:
WHERE
(@ByOwnLst = 'Owner' AND lo.owner IN (@OwnLst)
OR
(@ByOwnLst <> 'Owner' AND lo.lnum IN (@OwnLst)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top