The within group statement and group by are not related by half a cent. They are only auxiliary keywords of some single valued aggregate functions. Take the rank function as an example.
Rank is divided into aggregate function and analysis function in Oracle. This paper does not introduce analysis function, but refers to analysis function.
The rank syntax of aggregate function is: rank (expr1, expr2) within group (order by expr3, expr4 [desc/ASC] nulls [first/last])
it means to calculate the sort number of records with expr3 = expr1 and expr4 = expr2 in the result set with expr3 and expr4 as sort conditions, and return it as numeric type. The sorting is non compact, that is, if the first two records are the same, then the sorting number is 1, 1, 3… When using, it is not necessary to match with group by.
As long as you know the meaning of within group in the rank, you can’t learn to use it with other functions.
The functions that can use the within group keyword are rank and deny_ rank,PERCENT_ RANK,PERCENTILE_ CONT,PERCENTILE_ Disc, etc
Similar Posts:
- [Solved] must appear in the GROUP BY clause or be used in an aggregate function
- MYSQL Error: Invalid use of group function [How to Solve]
- How to solve Oracle ora-00937 Error: not a single group grouping function?
- [Solved] HiC-Pro mergeSAM.py Error: Forward and reverse reads not paired. Check that BAM files have the same read names and are sorted.
- Hive SemanticException:Expression not in GROUP BY
- Error: not a group by expression [How to Solve]
- [Solved] Query DataTables Error: Cannot reinitialise DataTable
- [Solved] Hive Run Error: Diagnostic Messages for this Task: Error: Java heap space
- MYSQL Error: Out of sort memory, consider increasing server sort buffer size; nested exception is java.sql.SQLException: Out of sort memory, consider increasing server sort buffer size
- Ora-04036: the PGA memory used by the instance exceeds PGA_ AGGREGATE_ LIMIT