Within Group function __ function

Source: Internet
Author: User

With Temp as (
Select population, ' Nation ', ' Guangzhou ' City and dual UNION all
Select 1500 population, ' nation ', ' Shanghai ' City and dual UNION all
Select population, ' Nation ', ' Beijing ' City and dual UNION all
Select 1000 population, ' USA ' Nation, ' New York ' city and dual UNION all
Select population, ' USA ' Nation, ' Bostom ' City and dual UNION all
Select population, ' Japan ' Nation, ' Tokyo ' city from dual
)
Select
Rank (+, ' Bf ') within GROUP (ORDER by population,city Desc) rank
from temp;

Description: According to 500 query, according to the Bf fuzzy query


With Temp as (
Select ' Nation ', ' Guangzhou ' City from dual union all
Select ' Nation ', ' Shanghai ' City from dual union all
Select ' Nation ', ' Beijing ' City from dual union all
Select ' USA ' Nation, ' New York ' city-dual UNION ALL
Select ' USA ' Nation, ' Bostom ' city-dual UNION ALL
Select ' Japan ' Nation, ' Tokyo ' city from dual
)
Select Nation,listagg (City, ', ') within GROUP (order by city DESC)
From temp
Group by Nation;

Description: Similar to the WM_CONCAT function, the data for row-level statistics.


With Temp as (
Select population, ' Nation ', ' Guangzhou ' City and dual UNION all
Select 1500 population, ' nation ', ' Shanghai ' City and dual UNION all
Select population, ' Nation ', ' Beijing ' City and dual UNION all
Select 1000 population, ' USA ' Nation, ' New York ' city and dual UNION all
Select population, ' USA ' Nation, ' Bostom ' City and dual UNION all
Select population, ' Japan ' Nation, ' Tokyo ' city from dual
)
Select population,
Nation
Listagg (city, ', ') within GROUP (order by city) over (partition by nation) rank
from temp;

Note: Use the over function to data row-level statistics, display the data of each row


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.