dcsimg
Results 1 to 3 of 3

Thread: select Case when query help

  1. #1
    Join Date
    Dec 2002
    Posts
    50

    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.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,918
    Not clear how you want P_CODE and E_CODE displayed. The current query is not syntactically correct.

  3. #3
    Join Date
    Dec 2002
    Posts
    50
    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
  •