Simple use case method of oracle database

  The case can change the value of check out the column values ​​selectivity. For chestnuts, there is a simple table as student table Student table has a gender field, but when the field type char (1) type, and gender want to remove the correlation between a Chinese show as follows: (1: Male , 2: female, 3: others) may be used where this case solved: to remove the student is now assumed that the table name, id, gender, (gender field for the corresponding Chinese alternative):

SELECT
    st.NAME,
    st.NAME,
CASE
    st.gender 
    WHEN '1' THEN
    '' 
    WHEN '2' THEN
    '' 
    WHEN '3' THEN
    '其他' 
END 
FROM
    student st

 

Guess you like

Origin www.cnblogs.com/notably/p/11913838.html