The SQL decode function assigns a value to the output field according to the corresponding field value of a table in the database. For example
SELECT decode(ID, 1, 'Apple', 2, 'Pear', 3, 'Papaya', 'Others') Fruit, PRICE from FRUIT;
The output has two columns, Fruit and PRICE. When the ID value in the FRUIT table in the database is 1 the Fruit value in the output will be Apple; when the ID is 2, the Fruit value will be Pear; when the ID value is 3, the Fruit value will be Papaya; and when the ID in the FRUIT table is neither 1 nor 2 nor 3, the Fruit value in the output. is Others.
-----------------------------------------------------------------------------------------------------------------
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.
SELECT decode(ID, 1, 'Apple', 2, 'Pear', 3, 'Papaya', 'Others') Fruit, PRICE from FRUIT;
The output has two columns, Fruit and PRICE. When the ID value in the FRUIT table in the database is 1 the Fruit value in the output will be Apple; when the ID is 2, the Fruit value will be Pear; when the ID value is 3, the Fruit value will be Papaya; and when the ID in the FRUIT table is neither 1 nor 2 nor 3, the Fruit value in the output. is Others.
References:
1. Decode-----------------------------------------------------------------------------------------------------------------
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.
No comments:
Post a Comment