We help IT Professionals succeed at work.

SQL Where statment help

267 Views
Last Modified: 2014-09-24
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')
Comment
Watch Question

Jim HornSQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015

Commented:
>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.

Author

Commented:
This covers 6 months.  So September2014 would turn into March2015, October2014 would turn into April2015 and so on.
Senior DBA
CERTIFIED EXPERT
Most Valuable Expert 2018
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
awking00Information Technology Specialist
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.