Oracle Advanced Find

Source: Internet
Author: User

1.rownum:rownum is a pseudo-column that needs to be rownum when the data is taken out, so a nested query is required for paging lookups.

SelectSal,ename from (SelectRowNum asRn,sal,ename from       (SelectSal,ename fromEmpwhereSal is  not NULL Order  bysal) xwhereRowNum<Ten)whereRn>6

The use of analytic functions can also be implemented once nested

Select  from       (Selectover,orderby aswhere is  not NULL ) xwherebetween6andten

However, due to the impact of the analysis function, some indexes may be invalid, we recommend that you use the first one.

Return data in interlaced order to find the pseudo-column, MOD (rn,x)

2.Merge: Efficient table update processing

 merge inot test ausing ( select  rowID as  rid,nbr100  +  rownum () over  (partition Span style= "color: #0000ff;" >by  NBR order  by  rowid) as  nnbr  test) b  on  (A.rowid=  b.rid)  when  matched update  set  a.nbr =  B.nnbr; 

Let's guess how many times the test watch scanned?????

3. Combine some of the columns in the table to

Step1: Row career

Select *  from  for inch (T1,T2,T3)

Unpivot a very good way to transpose the ranks

Step2: Sorting by value and merging

 with  x1 as   ( select   *  from  test Unpivot (B2 for  b3 in   select  ID, Listagg (B2, " ,   ) Within group  (order  by  B2)  b  from   X1  group  by  ID; 

After the Listagg is grouped, values are sorted and values are spliced by commas

Step3: Removing duplicates

 withX1 as   (Select *  fromTest Unpivot (B2 forB3inch(T1,T2,T3)), X2 as( SelectId,listagg (B2,',') withinGroup(Order  byB2) asb fromX1Group  byID)SelectId,b,row_number () Over(Partition byBOrder  byId assn fromX2

Oracle Advanced Find

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.