Avatar of lisa_mc
lisa_mc
Flag for United Kingdom of Great Britain and Northern Ireland asked on

using coalesce but showing greater value of two

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))) )

Open in new window

DatabasesMicrosoft SQL Server 2005SQL

Avatar of undefined
Last Comment
lisa_mc

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Lowfatspread

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
lisa_mc

ASKER
worked a treat thanks very much for your help
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy