-
select Case when query help
Hi - I have two tables (tbl1 and tbl2). based on m_code value in tbl1, I want to displayP_CODE and E_CODE fields in tbl2 certain way. Below is how I need to write my query to show how I need to display the field values, I appreciate if you please help me with correcting the query!
select
case
when e.m_code = 'S' then s.P_CODE = 1 and s.E_CODE = 1
when e.m_code = 'H' then s.P_CODE = 2 and s.E_CODE =1
when e.m_code = 'E' then s.P_CODE = 3 and s.E_CODE =1
when e.m_code = 'P' then s.P_CODE = 3 and s.E_CODE = 1
when e.m_code ='R' then s.P_CODE = 3 and s.E_CODE =1
end
from
tbl1 e
join tbl2 s on e.field = s.field
where s.m_code in (
'S',
'H',
'E',
'P',
'R')
Last edited by Lava; 10-23-2014 at 03:29 PM.
-
Not clear how you want P_CODE and E_CODE displayed. The current query is not syntactically correct.
-
I already resolved the issue, thank you..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|