Oracle SQL query exercise skills (this is very practical, not blow)

Source: Internet
Author: User

 

Table data;

Menu_id Is_tree
0001 1
0002 1
0101 2
0102  
0103  
0201 5
0202 6

 

 

 

 
-------------- Use the decode function select B. menu_id, decode (B. is_tree, '1', '1vv ', '2', '2vv', null, 'isullvalue', 'defaultvaluehe ') tree from menutree B -------------- use case when then else to achieve the same effect select C. menu_id, casewhen C. is_tree is null then 'isnullvalue' when C. is_tree = '1' then' 1vv 'when C. is_tree = '2' then' 2vv 'else' ultultvaluehe' end tree from menutree C

 

The above two SQL statements have the same effect.

 

 

 

Menu_id Tree
0001 1vv
0002 1vv
0101 2vv
0102 Isnullvalue
0103 Isnullvalue
0201 Defaultvaluehehe
0202 Defaultvaluehehe

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.