Link to home
Start Free TrialLog in
Avatar of MadIce
MadIce

asked on

Using Right() in case statement

I have a query like the following:

Select Item, StartDate,
Case when Right(lot, 1) in ('A', 'B', 'C') then 'Suffixed'
else '' end as ItemNote
From Table1

This doesn't seem to like the "IN ('A', 'B', 'C')". What can I use other then writing a long "Or This" string.
SOLUTION
Avatar of JestersGrind
JestersGrind
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Scott Pletcher
Yep, nothing wrong with that, it should work just fine.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MadIce
MadIce

ASKER

In the results it will add the note to all the ones it should but will also add to some that it shouldn't. For example:

www123-001
this one adds the note and shouldn't. where the following it doesn't:
www123-002.


The Right() seems to be no problem. I Took out the In portion and made it = 'A' just to test. No problem. I might just need to do update statements after the initial query. It just bugs me I can't see the issue. I also can't post the actual query for further help.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Madice, your issues was resolved?
If not, do you want to reformulate it?
Works for us.  Thanks for the split and for posting the eventual answer.  Good luck with your project.  -Jim
Avatar of MadIce

ASKER

Since the issue was a type O, I'm just spreading the points out for looking over the question. Thanks for the assistance. This should of been closed out before. Not sure what happen. Sorry for the delay.