troubleshooting Question

using coalesce but showing greater value of two

Avatar of lisa_mc
lisa_mcFlag for United Kingdom of Great Britain and Northern Ireland asked on
DatabasesMicrosoft SQL Server 2005SQL
2 Comments1 Solution291 ViewsLast Modified:
Hi everyone

small problem and can't seem to figure it out and would love help

Code below shows a link from one of my tables my problem is I have found a case where the withdrawn week is considerably greater than the end week which shouldn't be the case.

To cater for this I was wondering can you say coalesce these two values but whatever value is less (except NULL) display that value instead bearing in mind that I need to subtract 1 from the value withdrawn week.  I think I need coalesce because alot of the times withdrawn week can be null - maybe there is another way to do this im not sure?

Help appreciated

thanks
and ( (a.week_no >= b.starting_week)
and (a.week_no <= (coalesce (b.withdrawn_week -1, b.end_week))) )
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros