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_reclassificat ion = 'N', date_last_modified = getdate(), last_maintained_by = 'ABIX_DBA'
where exclude_from_ranking = 'Y' and exclude_from_reclassificat ion = 'Y'
and purchase_class_id in ('N11', 'N12', 'N01', 'N02', 'N09', 'N10', 'NS')
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_reclassificat
where exclude_from_ranking = 'Y' and exclude_from_reclassificat
and purchase_class_id in ('N11', 'N12', 'N01', 'N02', 'N09', 'N10', 'NS')
ASKER
This covers 6 months. So September2014 would turn into March2015, October2014 would turn into April2015 and so on.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Explain how N09 becomes N03. Not getting it.