oracle - select rows and generate a new column based on condition SQL -
i have following table in oracle
company   rate   period 1a        10     sep-16 1b        20     sep-15 1c        30     oct-16 1d        40     sep-16 1a        50     oct-16 2b        50     sep-15 1c        60     oct-14   i want select rows , add value based on conditions. result similar following:
company   rate   period    currency 1a        50     oct-16    usd 1c        30     oct-16    aed   in previous table, selecting companies 1a, 1c period ='oct-16'. , need add column "currency" each company 1a=usd, 1c=aed
what did is:
select company, period , rate  table_test  period='oct-16' , company='1a'      or period='oct-16' , company='1c';   i managed companies failed @ currency column. possible using sql command? please help.
yes possible using case condition:
    select company,rate,period,(case when company='1a' 'usd'                                       when company='1c' 'aed' end                                     )currency     table_test     period='oct-16'     , company in ('1a','1c')      
Comments
Post a Comment