Example This example decodes the value warehouse_id. If warehouse_id is 1, the function returns 'Southlake'; if warehouse_id is 2, it returns 'San Francisco'; etc. If warehouse_id is not 1, 2, 3, or 4, the function returns 'Non-domestic'. SELECT product_id, DECODE (warehouse_id, 1, 'Southlake', 2, 'San Francisco', 3, 'New Jersey', 4, 'Seattle', 'Non-domestic') quantity_on_hand FROM inventories;
不对写错了. 是TO ern(学习Oracle) 有很多的不同的数据呀.
decode的用法: select decode(a.name,'AA','1','BB','2',....,'0') from tablename a where ..... 从表tablename中选择name字段,如果有'AA'就用1代替,如果有'BB',就用2代替.....如果前面的都没有,就用0代替.
replace('1年','一年')不就搞定了?、
如果是只修改显示的部分,translate函数也行
This example decodes the value warehouse_id. If warehouse_id is 1, the function returns 'Southlake'; if warehouse_id is 2, it returns 'San Francisco'; etc. If warehouse_id is not 1, 2, 3, or 4, the function returns 'Non-domestic'. SELECT product_id,
DECODE (warehouse_id, 1, 'Southlake',
2, 'San Francisco',
3, 'New Jersey',
4, 'Seattle',
'Non-domestic')
quantity_on_hand FROM inventories;
是TO ern(学习Oracle)
有很多的不同的数据呀.
select decode(a.name,'AA','1','BB','2',....,'0') from tablename a where .....
从表tablename中选择name字段,如果有'AA'就用1代替,如果有'BB',就用2代替.....如果前面的都没有,就用0代替.
或者更多不同的数据,我都要写在DECODE的内呀.
有没有更通用的方法.