Link to home
Start Free TrialLog in
Avatar of Amour22015
Amour22015

asked on

SQL Server 2014 - Case When to Check condition

Hi Experts,


I have a case when statement
when cce.CVA_StatusID is not null then cvs.StatusType else 'No Status' end as [Status]

Open in new window


and would like to do:
INNER JOIN  @SEV as sta on sta.stat = Status

But one can see this is not the correct way to do this.

Any idea would be great?  Maybe a CTE?  but would need help.

Thank You....
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Please post your whole SQL Statement, as it's really not clear what you are asking us.
Try

...INNER JOIN  @SEV as sta on sta.stat = case when cce.CVA_StatusID is not null then cvs.StatusType else 'No Status' end

Open in new window

I agree with Jim.
If you post the entire query it will more easier for us to help you.
Avatar of Amour22015
Amour22015

ASKER

Yes it looks like I have to do a nested join on the whole query.  Otherwise I could get negative results.   So I have to take the whole query and put into a CTE that way it will give the Status then do the INNER JOIN...  Sorry can not post whole query which makes it hard.  Just looking for idea's on how to do.  And I guess there is not other way...



Thanks
SOLUTION
Avatar of Jim Horn
Jim Horn
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
ASKER CERTIFIED 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
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
Thank you all for helping