Link to home
Start Free TrialLog in
Avatar of abarefoot
abarefoot

asked on

SQL Where statment help

The last part of the WHERE needs to be different every month; the numbers behind "N##" correspond to a month.  They need to roll forward each month - the below script is setup for August, but for September, the N09 needs to change to N03; in October, the N10 would change to N04, and so on.   ' NS' doesn't change and is constant.

I've tried CASE, but can't get it to hit multiple fields.  One thought was to use a series of SQL jobs to update a temp table with the proper number series each month.  Another was to build some if/then into SSRS.

update purchase_class
set exclude_from_ranking = 'N', exclude_from_reclassification = 'N', date_last_modified = getdate(), last_maintained_by = 'ABIX_DBA'
where exclude_from_ranking = 'Y' and exclude_from_reclassification = 'Y'
and purchase_class_id in ('N11', 'N12', 'N01', 'N02', 'N09', 'N10', 'NS')
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

>but for September, the N09 needs to change to N03; in October, the N10 would change to N04, and so on.
Explain how N09 becomes N03.  Not getting it.
Avatar of abarefoot
abarefoot

ASKER

This covers 6 months.  So September2014 would turn into March2015, October2014 would turn into April2015 and so on.
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
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
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