Amour22015
asked on
SQL Server 2014 - Case When to Check condition
Hi Experts,
I have a case when statement
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....
I have a case when statement
when cce.CVA_StatusID is not null then cvs.StatusType else 'No Status' end as [Status]
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....
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
I agree with Jim.
If you post the entire query it will more easier for us to help you.
If you post the entire query it will more easier for us to help you.
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
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
Thank you all for helping