CodeMantis
CodeMantis

Reputation: 85

Rename data from Oracle Column

I would like to rename certain data from an oracle table. Lets assume the data in table "Random Items" has the form

Day      Item      Total

12/3     102         12

12/3     423         28 

12/4     102         48

I would like to rename the Item number to a specific string so when I grab the data from the table the output will look like

Day      Item           Total

12/3     Shoe           12

12/3     Orange         28 

12/4     Shoe           48

so Shoe = 102 and Orange = 423

I have no writing writes to the tables. I've looked at commands such as rename, synonym and replace but they all rename a specific table or column. I would like to reverence the data in the table.

Thank you

Upvotes: 0

Views: 834

Answers (2)

Ertunç
Ertunç

Reputation: 829

select day, case ITEM when 102 then 'shoe'
                    when 423 then 'orange'
        end itemname, total
from items

Upvotes: 3

Victor Grimaldo
Victor Grimaldo

Reputation: 58

try using decode like:

select day, decode(item, '102', 'Shoe', '423', 'Orange',...), total from items

Upvotes: 0

Related Questions