Code Word SQL (7)

Source: Internet
Author: User

The WITH clause supports starting with Oracle 9i
  
 
  1. --不用connect by,只用dual表,构造出1到128
  2. with a as ( select 1 from dual union all select 1 from dual )
  3. select rownum from a, a, a, a, a, a, a;
  4. --做一个5*5的乘法表
  5. with multiplier as ( select rownum n From dual connect by rownum < 6 )
  6. select a n | | ' * ' | | b n | | ' = ' | | ( a n * b n from multiplier a multiplier b ;
For the second SQL to use Connect by, now just know it is possible, do not need to know why. If you have a brave heart, you can ask Niang. It is estimated that a day or a day is needed to ascertain the changes. It is also worth mentioning that this type of writing in different database support is different, preferably not nested, although in 11g no problem, but in 9i and 10g is hard to say. Nesting refers to a similar: with a as below to see an application problem with SQL solution there are cows and geese on the edge of the pond, and Xiao Hua sees 15 head and 42 legs in total, how many cows and geese are there?


From for notes (Wiz)

Code Word SQL (7)

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.